I have 1 list A containing 2 vectors and 1 vector B. I want to insert B into A such that B is in the first position.
I have this:
A <- list(LETTERS, letters)
B <- 1:10
I want this:
A <- list(B, A[[1]], A[[2]])
I currently do this:
B <- list(B)
for (i in 1:length(A)) {
B[i+1] <- A[[i]]}
Is there a better way without using for
loops?