I have a function which check for me my list. I have a list with two vectors. instead of repeating my code, I tried to use for
loop. However, the for loop does not work as expected.
Here is my code:
x <- c(2,3,4,5)
y <- c(2,4,6,7)
z <- list(x,y)
pscale <- numeric()
pscale <- list()
for(i in 1:4){#length of my vector
for(j in 1:2){#length of z
pscale[[j]][[i]] <- ifelse(z[[j]][[i]] %in% c(2,9,10),0.01,1)
}
}
Error in `*tmp*`[[j]] : subscript out of bounds