dim 행렬이 5 개 1000*35
있습니다. 5*35
첫 번째 행렬이 5 개의 이전 행렬의 첫 번째 행에서 생성되도록 1000 개의 새로운 dim 행렬을 만들고 싶습니다 . 두 번째 행렬은 5 개의 이전 행렬의 두 번째 행에서 생성됩니다.
내가 어떻게 해? 나를 안내 해주세요.
for()
루프를 사용할 수도 있습니다 . 다음은 자세한 예입니다.
# old matrices
old.mat1 <- matrix(data = sample(35000), nrow = 1000, ncol = 35)
old.mat2 <- matrix(data = sample(35000), nrow = 1000, ncol = 35)
old.mat3 <- matrix(data = sample(35000), nrow = 1000, ncol = 35)
old.mat4 <- matrix(data = sample(35000), nrow = 1000, ncol = 35)
old.mat5 <- matrix(data = sample(35000), nrow = 1000, ncol = 35)
rbind(old.mat1[1, ], old.mat2[1, ], old.mat3[1, ], old.mat4[1, ],
old.mat5[1, ]) # how we will build new matrices
dim(rbind(old.mat1[1, ], old.mat2[1, ], old.mat3[1, ], old.mat4[1, ],
old.mat5[1, ])) # you can see that dim is 5*35
new.mat <- list() # list of new matrices
for(i in 1:1000){
new.mat[[i]] <- rbind(old.mat1[i, ], old.mat2[i, ], old.mat3[i, ],
old.mat4[i, ], old.mat5[i, ])
}
new.mat1 <- new.mat[[1]] # first new matrix
length(new.mat) # new.mat contains the 1000 new matrices
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다