how can i tell select() in dplyr that the string it is seeing is a column name in a data frame

后端 未结 8 856
感动是毒
感动是毒 2020-12-24 11:15

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

8条回答
  •  情歌与酒
    2020-12-24 11:47

    I ran across this and I thought I should mention that this has been solved in newer versions of dplyr.

    myTest = data_frame(
      var1 = 1, 
      var2 = 2,
      var3 = 3,
      var4 = 4)
    
    i = 1
    
    myTest %>%
      select_(.dots = 
         c(names.gens[i,1], names.gens[i,2]) %>% unname)
    

提交回复
热议问题