首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >更新: Plyr rename()不识别相同的'x';错误:`x‘中没有出现以下` `from`’值:

更新: Plyr rename()不识别相同的'x';错误:`x‘中没有出现以下` `from`’值:
EN

Stack Overflow用户
提问于 2016-03-17 18:34:28
回答 1查看 775关注 0票数 0

3.2.4更新2016-03-10

我试图在一个大数据集中重命名列,并运行到“from值不存在于x中:”错误。

从原始导出的列是可怕的,这就是为什么我使用plyr重命名,但似乎连重命名都有问题。示例故障列是,3在链接数据集中,标题为:

"Experimental.or.quasi.experimental..evaluation..compares.mentored.youth.to.a.comparison.or.â.œcontrolâ...group.of.non.mentored.youth..NS8“

下载到csv 这里的链接:下面的代码:

代码语言:javascript
复制
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"))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-17 19:12:03

试着使用setNames来代替:

代码语言:javascript
复制
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"   
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36068960

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档