I have a large number of matrix, calls train which is a binary data with 1 and 0
I want to extract and make another two lists which contains 1 as list1 and 0 as list2 by using for loop
my R code is not working
X <- c(0,1,0,1,0,1)
Y <- c(1,1,1,1,1,0)
train<- as.matrix (cbind(X,Y))
list1 <- list()
list2 <- list()
for(i in 1:length(train)) {
if(train[i]== 1)
list1 = train[i]
else
list2 = train[i]
}
Therefore I want my list1 to contain (1,1,1,1,1,1,1) and list2 to contain (0,0,0,0)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…