基于r中的另一个数据帧重命名列
我的列标题不正确。我想根据数据框架(第一列的名称对应我的数据框架的第一个标题),将矩阵的所有列重命名(因为我具有V1,V2,V3,..)。我必须重复39列。因此,目标是做一个循环。
DF1是必须更改的矩阵。
for (i in 1:39) {
names(df1[,i]) <- names(dfnorm[,i])
}
此代码不起作用。
My column titles are not correct. I want to rename all my column of a matrix (because i have v1,v2,v3,..) according to data frame (the name of the first column corresponds to the first title of my data frame). I have to repeat this for my 39 columns. So the goal would be to do a for-loop.
df1 is the matrix that has to be changed.
for (i in 1:39) {
names(df1[,i]) <- names(dfnorm[,i])
}
This code is not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解,这应该有效:
If I understand correctly, this should work: