Home One more tidyr, gather and use of variables

# One more tidyr, gather and use of variables

user1700890
1#
user1700890 Published in 2017-12-04 20:24:17Z
 Here is my code: library(tidyr) messy <- data.frame( name = c("Wilbur", "Petunia", "Gregory"), a = c(67, 80, 64), b = c(56, 90, 50) )  And I would like to use gather function with variable/function result. Borrowing from I tried: not_messy <-messy %>% gather_('drug', 'heartrate', paste0('a',''):paste0('b',''))  But it generated error: Error in paste0("a", ""):paste0("b", "") : NA/NaN argument In addition: Warning messages: 1: In lapply(.x, .f, ...) : NAs introduced by coercion 2: In lapply(.x, .f, ...) : NAs introduced by coercion  What am I missing?
MrFlick
2#
 With the latest version of the tidyverse functions, you are discouraged from using the underscore versions of the function for standard evaluation and instead use the rlang function syntax. In this case you can use gather(messy, "drug", "heartrate", (!!as.name("a")):(!!as.name("b")))