Updated: Plyr rename() not recognizing identical 'x'; Error: The following `from` values were not present in `x`:
Updated: Plyr rename() not recognizing identical 'x'; Error: The following `from` values were not present in `x`:
R 3.2.4
Plyr 更新于 2016-03-10
我正在尝试重命名大型数据集中的列并 运行 进入 "The following from
values were not present in x
:" 错误。
origin 导出的列非常糟糕,这就是我使用 plyr rename 的原因,但似乎即使 rename 也有问题。示例故障列是 linked 数据集中的 [3],标题为:
"Experimental.or.quasi.experimental..evaluation..compares.mentored.youth.to.a.comparison.or.â.œcontrolâ...group.of.non.mentored.youth..NS8"
下载 link 到 csv here:
代码如下:
test<-read.csv(file="test.csv",header=TRUE)
library(plyr)
test2<-rename(test,
c(
"Experimental.or.quasi.experimental..evaluation..compares.mentored.youth.to.a.comparison.or.â.œcontrolâ...group.of.non.mentored.youth..NS8"="new"))
尝试改用 setNames:
library(plyr)
test2 <- rename(test, setNames( "new", names(test[3])))
names(test2)
[1] "Implementation.evaluation..examines.how.well.or.efficiently.services.were.delivered.to.participants..such.as.tracking.mentor.mentee.meetings..participation.in.trainings..etc....NS8"
[2] "Outcome.evaluation..examines.changes.in.participants.served.using.pre.post.data.collection..NS8"
[3] "new"
[4] "Return.on.investment.study..examines.long.term.impacts.from.an.economic.perspective..often.in.relation.to.program.costs..NS8"
R 3.2.4 Plyr 更新于 2016-03-10
我正在尝试重命名大型数据集中的列并 运行 进入 "The following from
values were not present in x
:" 错误。
origin 导出的列非常糟糕,这就是我使用 plyr rename 的原因,但似乎即使 rename 也有问题。示例故障列是 linked 数据集中的 [3],标题为:
"Experimental.or.quasi.experimental..evaluation..compares.mentored.youth.to.a.comparison.or.â.œcontrolâ...group.of.non.mentored.youth..NS8"
下载 link 到 csv here: 代码如下:
test<-read.csv(file="test.csv",header=TRUE)
library(plyr)
test2<-rename(test,
c(
"Experimental.or.quasi.experimental..evaluation..compares.mentored.youth.to.a.comparison.or.â.œcontrolâ...group.of.non.mentored.youth..NS8"="new"))
尝试改用 setNames:
library(plyr)
test2 <- rename(test, setNames( "new", names(test[3])))
names(test2)
[1] "Implementation.evaluation..examines.how.well.or.efficiently.services.were.delivered.to.participants..such.as.tracking.mentor.mentee.meetings..participation.in.trainings..etc....NS8"
[2] "Outcome.evaluation..examines.changes.in.participants.served.using.pre.post.data.collection..NS8"
[3] "new"
[4] "Return.on.investment.study..examines.long.term.impacts.from.an.economic.perspective..often.in.relation.to.program.costs..NS8"