I tried searching but didn't find an answer to this question.
I'm trying to use the select statement in dplyr but am having problems when I try to send it strings. My question is, how do i tell select() that the string that it is seeing is a column name in the data frame?
e.g. this works fine
select(df.main.scaled, var1, var3)
select(df.main.scaled, var2, var4)
select(df.main.scaled, names.gens[i,1], names.gens[i,2])
> names.genx <- c("var1","var2")
> names.geny <- c("var3","var4")
> names.gens <- cbind(names.genx, names.geny)
[1,] "var1" "var3"
[2,] "var2" "var4"
I figured it out through trial and error. If anybody is curious, did something like this:
lapply(names.gens, as.name) select(df.main.scaled, eval(names.gens[[i]]), eval(names.gens[[i+someindex]]))