当前位置:网站首页>Filter error in dplyr: can't transform a data frame with duplicate names
Filter error in dplyr: can't transform a data frame with duplicate names
2022-06-30 11:25:00 【Analysis of breeding data】
background
Process a data frame , use filter When filtering data , Found this error :
aa1 %>% filter(POS_strt == “20696”)
Error infilter():
! Can’t transform a data frame with duplicate names.
Runrlang::last_error()to see where the error occurred.
Follow the prompts to run :rlang::last_error(), I didn't see the problem :
> rlang::last_error()
<error/rlang_error>
Error in `filter()`:
! Can't transform a data frame with duplicate names.
---
Backtrace:
1. aa1 %>% filter(POS_strt == "20696")
3. dplyr:::filter.data.frame(., POS_strt == "20696")
Run `rlang::last_trace()` to see the full context.
I've been searching the Internet for a long time , It's finally settled , To sum up .
Problem solving
This is mainly because the column names in the data frame are duplicate , In fact, the error report also gives :
! Can’t transform a data frame with duplicate names.
however , I thought it was rownames Repeat , It's actually colnames Repeat , Check it out here :
names(aa1) %>% duplicated() %>% table

You can see , There is a repetition .
use make.names Process the following name , Duplicate suffix plus .1
nn = names(aa1)
names(aa1) = make.names(nn,unique = T)
names(aa1)

You can see , The red box in the picture ,Chrom.1 The name has changed , After this treatment , There will be no repetition . Test it :

Get it done !
summary
tidyverse Data frame , There must be no duplicate column names , No filter Such functions cannot be used . The solution can be base In bag make.names Handle , Rename .
边栏推荐
- 【leetcode 16】三数之和
- Train an image classifier demo in pytorch [learning notes]
- 数字化不是试出来,而是蹚出来的|行知数字中国 × 富士康史喆
- 再测云原生数据库性能:PolarDB依旧最强,TDSQL-C、GaussDB变化不大
- R语言去重操作unique duplicate filter
- 8 lines of code to achieve quick sorting, easy to understand illustrations!
- datax json说明
- Wireguard simple configuration
- OLAP数据库引擎如何选型?
- ArrayList and sequence table
猜你喜欢

数据库连接池 druid
![200000 bonus pool! [Alibaba security × ICDM 2022] the risk commodity inspection competition on the large-scale e-commerce map is in hot registration](/img/0e/19c4c97a582d7b2ad08ce806d7af03.jpg)
200000 bonus pool! [Alibaba security × ICDM 2022] the risk commodity inspection competition on the large-scale e-commerce map is in hot registration

相对位置编码Transformer的一个理论缺陷与对策

Time complexity and space complexity

Cp2112 teaching example of using USB to IIC communication

How to analyze native crash through GDB

Deep dive kotlin synergy (16): Channel

win10 R包安装报错:没有安装在arch=i386

OLAP数据库引擎如何选型?

Handler-源码分析
随机推荐
iptables目标TPROXY
优惠券种类那么多,先区分清楚再薅羊毛!
Iptables target tproxy
Introduction to China Mobile oneos development board
datax json说明
考研这些“不靠谱”的经验有多害人?
100 important knowledge points that SQL must master: using subquery
Key library function based on Hal Library
ESP32-C3入门教程 基础篇⑫——量产烧写设备配置和序列号, NVS partition分区确认, NVS 分区生成程序, csv转bin
语音信号处理-基础(五):傅立叶变换
IDEA 又出新神器,一套代码适应多端!
单片机 MCU 固件打包脚本软件
LeetCode Algorithm 86. 分隔鏈錶
[leetcode 239] sliding window
阿里云李飞飞:中国云数据库在很多主流技术创新上已经领先国外
Discussion on the essence of "FPGA mining" from open source projects
TypeScript ReadonlyArray(只读数组类型) 详细介绍
LVGL 8.2 Image styling and offset
100 important knowledge points that SQL must master: updating and deleting data
微信表情符号被写入判决书,你发的每个 emoji 都可能成为呈堂证供