I’m looking to take 79 columns and make a unique variable for each column.
I can manually create the variables by subsetting:
v1 <- x[1]
v2 <- x[2]
etc.
I was wondering if/know there’s a much faster way to do it. I’m just not really sure how.
Right now I have:
test <- matrix(rep(1,79), nrow = 1, ncol = 79)
c2v <- function(test){
for (i in c(1:79){
v[i] <- test[i]
}
return(v[i])
}
c2v(test)
Thanks as always for the help!
Jon
What about something like:
I’m sure it could be reconfigured to get rid of the loop, but this should work.
Future me editing my past mistakes:
Something like the following may be a more appropriate non-loop solution.
It is probably still better practice to work with a
data.frameorlistthan breaking up to individual vectors.