1
我懷疑這是一個處理NSE的問題。但爲什麼這兩種方法不起作用,我怎麼才能讓他們工作。purrr和ggplot函數不顯示陰謀(NSE問題)
temp1 <- function(x){
iris %>%
ggplot(aes(Sepal.Length, Sepal.Width)) +
geom_point() +
facet_wrap(as.formula(paste("~", x)))
}
walk('Species', temp1)
temp2 <- function(x){
x <- as.name(x)
iris %>%
ggplot(aes(Sepal.Length, Sepal.Width)) +
geom_point() +
facet_wrap(~ x)
}
walk('Species', temp2)
這很有道理。你可以評論爲什麼做(或者)通過管道不起作用。那是'...%>%print()'。 – student
@student,因爲如果你使用簡單的管道,你會將'facet_wrap()'對象傳遞給'print'。如果你想要管道,你可以用'()'分組整個東西,然後傳給'print'。像'(虹膜%>%...)%>%print()' –