Home One more tidyr, gather and use of variables
Reply: 0

One more tidyr, gather and use of variables

user705
1#
user705 Published in April 25, 2018, 12:35 pm

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?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.471759 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO