R rbind error row.names duplicates not allowed

为君一笑 提交于 2019-12-03 12:37:50

I had the same error recently. What turned out to be the problem in my case was one of the attributes of the data frame was a list. After casting it to basic object (e.g. numeric) rbind worked just fine.

By the way row name is the "row numbers" to the left of the first variable. In your example, it is 1, 2, 3, ... (the same as your id variable).

You can see it using rownames(df) and set it using rownames(df) <- name_vector (name_vector must have the same length as df and its elements must be unique).

I had the same error.

My problem was that one of the columns in the dataframes was itself a dataframe. and I couldn't easily find the offending column

data.table::rbindlist() helped to locate it

library(data.table)
rbindlist(a)
# Error in rbindlist(a) : 
#   Column 25 of item 1 is length 2 inconsistent with column 1 which is length 16. Only length-1 columns are recycled.


a[[1]][, 25] %>% class # "data.frame" K- this should obviously be converted to a column or removed

After removing the errant columndo.call(rbind, a) worked as expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!