I want to select all columns in my dataframe which I have stored in a string variable. For example:
v1 <- rnorm(100)
v2 <- rnorm(100)
v3 <- rnorm(100)
df <- data.frame(v1,v2,v3)
I want to accomplish the following:
df[,c('v1','v2')]
But I want to use a variable instead of (c(‘v1’, ‘v2’))(these all fail):
select.me <- "'v1','v2'"
df[,select.me]
df[,c(select.me)]
df[,c(paste(select.me,sep=''))]
Thanks for help with a simple question,
This is basic
Rsytnax, perhaps you need to read the introductory manual