bind_rows引发错误-无法结合1.activity.id和`..2 $ activity ID`< factor< 2585 [英] bind_rows is throwing an error - can't combine 1.activity.id and `..2$activity ID` <factor<2585
本文介绍了bind_rows引发错误-无法结合1.activity.id和`..2 $ activity ID`< factor< 2585的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码就是这样
if (startsWith(i, "CombinedReport_2")) {
temp1 <- read.csv(paste(directory, i, sep = ""), header = TRUE)
if (ncol(temp1) < 19) {
names(temp1) <- dfCombinedNamesOld
}
else {
names(temp1) <- names(dfCombined) `dfcombined and fdcombinedold are empty dataframes with headers
}
dfCombined <- bind_rows(dfCombined,temp1)
}}
这很奇怪,因为我试图合并到dfCombined中的目录中大约有11个文件,而所有文件的结构都像这样:
This is strange because i have about 11 files in the directory that it's trying to merge into dfCombined and the structure for all of them is like this:
'data.frame': 7681 obs. of 19 variables:
$ ï..Activity.ID : Factor w/ 2938 levels "CBCC-1E1EELE",..: 23 23 23 39 39 39 39 39 39 39 ...
$ Type : Factor w/ 5 levels "Attendee List",..: 3 3 3 3 3 3 3 3 3 3 ...
$ Activity.Subtype : Factor w/ 14 levels "1. IMW â\200" Introduction",..: 5 5 5 4 4 4 4 4 4 4 ...
$ Created.Date : Factor w/ 2936 levels "2019-01-01 23:27:54",..: 23 23 23 40 40 40 40 40 40 40 ...
$ Due.Date : Factor w/ 83 levels "2019-08-01 00:00:00",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Modified.By : Factor w/ 55 levels "imrankhan","imrankhan",..: 10 10 10 38 38 38 38 38 38 38 ...
$ Modified : Factor w/ 2851 levels "2019-06-27 11:35:59",..: 538 538 538 331 331 331 331 331 331 331 ...
$ Completed.Date : Factor w/ 2001 levels "","2019-06-27 11:35:58",..: 19 19 19 10 10 10 10 10 10 10 ...
$ Subject : Factor w/ 1319 levels "$2 Million Opp",..: 1167 1167 1167 644 644 644 644 644 644 644 ...
$ Fiscal_Quarter : int 4 4 4 4 4 4 4 4 4 4 ...
$ Fiscal_Year : int 2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 ...
$ Expense.Type : Factor w/ 12 levels "","Movie",..: 9 9 9 9 9 9 9 9 9 9 ...
$ Expense.Amount : num 211 211 211 581 581 ...
$ Cost.per.Contact : num 52.8 52.8 52.8 23.2 23.2 ...
$ Contact.ID : Factor w/ 4705 levels "CBCC-1E1EELE",..: 2032 2825 3365 77 334 1018 1406 1593 2350 2430 ...
$ Full.Name : Factor w/ 4676 levels "Alex Khong",..: 4073 2896 3979 142 3587 1695 115 2798 280 3942 ...
$ Branch : Factor w/ 1705 levels "","100 MILE HOUSE-9962-001041",..: 353 363 353 117 117 117 117 117 117 117 ...
$ Primary Code: Factor w/ 3406 levels "","-","7584-0858",..: 2239 1 1 1 1 1 980 973 983 982 ...
$ Sub.Region : Factor w/ 38 levels "CF","DR","EC51",..: 31 31 31 3 3 3 3 3 3 3 ...
bind_rows为什么抛出错误```错误:无法将 .. 1 $ Activity ID
和 .. 2 $ Activity ID
< factor< 2585d>>.
Why is bind_rows throwing an error ```Error: Can't combine ..1$Activity ID
and ..2$Activity ID
<factor<2585d>>.
推荐答案
虽然不灵活,但我继续使用rbind来解决问题.仍然无法找出导致Bind_rows失败的原因.
While inflexible, i went ahead with rbind which solved the problem for now. Still not able to figure out what caused Bind_rows to fail.
这篇关于bind_rows引发错误-无法结合1.activity.id和`..2 $ activity ID`< factor< 2585的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文