【发布时间】:2018-05-18 09:25:27
【问题描述】:
这是我的代码:
library(tidyr)
messy <- data.frame(
name = c("Wilbur", "Petunia", "Gregory"),
a = c(67, 80, 64),
b = c(56, 90, 50)
)
我想将gather 函数与变量/函数结果一起使用。借from我试过了:
not_messy <-messy %>%
gather_('drug', 'heartrate', paste0('a',''):paste0('b',''))
但它产生了错误:
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
我错过了什么?
【问题讨论】: