从 tidyr compains 收集有关未找到对象的信息
gather from tidyr compains about object not found
我有这段工作代码:
number_of_columns <- dim(resultsper)[2]
resultsper <- resultsper %>% gather(c(5:number_of_columns), key = "Scenario", value = "Value")
这过去工作正常,但现在,我收到消息
Error in FUN(X[[i]], ...) : object 'number_of_columns' not found.
如果我运行
resultsper <- resultsper %>% gather <- (c(5:11), key = "Scenario", value = "Value")
它又能用了,但这不是我想要的。我试过 gather_ 但这也不起作用。可能是 tidyr 的更新,但我还没有找到解决方案。
提前致谢
仁儿
从 tidyr 0.7.0 开始,选择规则更加严格。可以在 this article.
中查看 versino 0.7.0 中的所有更改
简而言之,当使用上下文表达式(即,使用数据集外的信息)时,您必须使用准引号运算符 [= 明确指出在哪里可以找到对象11=].
这是您的场景中的示例。
number_of_columns = ncol(mtcars)
mtcars %>% gather("Scenario", "Value", !! 5:number_of_columns)
我有这段工作代码:
number_of_columns <- dim(resultsper)[2]
resultsper <- resultsper %>% gather(c(5:number_of_columns), key = "Scenario", value = "Value")
这过去工作正常,但现在,我收到消息
Error in FUN(X[[i]], ...) : object 'number_of_columns' not found.
如果我运行
resultsper <- resultsper %>% gather <- (c(5:11), key = "Scenario", value = "Value")
它又能用了,但这不是我想要的。我试过 gather_ 但这也不起作用。可能是 tidyr 的更新,但我还没有找到解决方案。
提前致谢
仁儿
从 tidyr 0.7.0 开始,选择规则更加严格。可以在 this article.
中查看 versino 0.7.0 中的所有更改简而言之,当使用上下文表达式(即,使用数据集外的信息)时,您必须使用准引号运算符 [= 明确指出在哪里可以找到对象11=].
这是您的场景中的示例。
number_of_columns = ncol(mtcars)
mtcars %>% gather("Scenario", "Value", !! 5:number_of_columns)