我有一个形状正确的空矩阵(行和行)。我想一次将一列分配给该矩阵。
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']
答案 0 :(得分:0)
这可以做到。
allf[,'AA'] <- someothermatrix[,'xyz']