[英]R: how to assign columns to a matrix by column-name
我有一个形状正确的空矩阵(列和行)。 我想一次将列分配给这个矩阵。
allf <- matrix(0, nrow = 2*h, ncol = ncol(ally))
colnames(allf)<- colnames(train)
Here, allf has columns from AA, AB.... AZ.
Now, I want to assign the values by column name. As in:
allf.AA <- someothermatrix['xyz']
这会做到的。
allf[,'AA'] <- someothermatrix[,'xyz']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.