【发布时间】:2021-11-24 10:33:58
【问题描述】:
您能帮我在我的结局矩阵中获得自定义的暗名吗?
mat=matrix(nrow = 1, ncol = 5) #create empty matrix to hold values
#run for loop to generate random numbers and append to matrix
for(i in 1:2) {
rad5 = matrix(runif(n=5, min = 0, max = 3+i),nrow = 1, ncol = 5, dimnames = list(c("row_Name1"), c(paste0("col",letters[1:5]))))
#mat[i,] <- rad5
mat = rbind(mat[i], rad5)
}
这是我想要的示例。谢谢
> mat
cola colb colc cold cole
row_Name1 2.559102 2.559102 2.559102 2.5591017 2.559102
row_Name2 1.466036 4.942660 1.833257 0.7989867 3.981458
【问题讨论】: