ggplot2 facet_wrap中的错误:谓词必须是闭包。 CRAN版的tidyverse

时间:2018-04-20 15:37:30

标签: r ggplot2 tidyverse

我在ggplot2中使用facet_wrap收到错误:"错误:predicate必须是闭包或函数指针"

使用facet_grid时没有问题。

这似乎与本文中描述的问题相同(我会将此作为评论发布,但是没有足够的信誉这样做。此外,响应似乎将问题归因于使用开发ggplot的版本。我使用从CRAN安装的tidyverse版本): ggplot2 facet_wrap Error: predicate must be a closure

还有其他人遇到这种情况吗?谢谢!

# Install from CRAN
# install.packages("tidyverse")
library(tidyverse)

mtcars %>%
  ggplot(aes(mpg,wt)) +
  geom_point() +
  facet_wrap(~cyl)
# This fails with message: 
# Error: `predicate` must be a closure or function pointer

mtcars %>%
  ggplot(aes(mpg,wt)) +
  geom_point() +
  facet_grid(cyl~carb)
# This works

# Session info
# R version 3.4.4 (2018-03-15)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows >= 8 x64 (build 9200)
# 
# Matrix products: default
# 
# locale:
#   [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
# [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
# [5] LC_TIME=English_United States.1252    
# 
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#   [1] forcats_0.3.0      stringr_1.3.0      dplyr_0.7.4        purrr_0.2.4       
# [5] readr_1.1.1        tidyr_0.8.0        tibble_1.4.2       ggplot2_2.2.1.9000
# [9] tidyverse_1.2.1   
# 

0 个答案:

没有答案