以下示例直接来自帮助页面?geom_bar
:
g <- ggplot(mpg, aes(class))
g + geom_bar()
这会Error: Aesthetics must be either length 1 or the same as the data (7): width
跟踪:
11: stop("Aesthetics must be either length 1 or the same as the data (",
n, "): ", paste(names(!good), collapse = ", "), call. = FALSE)
10: check_aesthetics(params[aes_params], nrow(data))
9: f(..., self = self)
8: self$geom$use_defaults(data, self$aes_params)
7: f(..., self = self)
6: l$compute_geom_2(d)
5: f(l = layers[[i]], d = data[[i]])
4: by_layer(function(l, d) l$compute_geom_2(d))
3: ggplot_build(x)
2: print.ggplot(x)
1: function (x, ...)
UseMethod("print")(x)
这是一个错误,一个冲突的包或其他什么?
以下会话信息。
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.1
locale:
[1] LC_CTYPE=C LC_NUMERIC=C LC_TIME=C LC_COLLATE=C LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] parallel grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] doParallel_1.0.10 iterators_1.0.8 crunch_0.1.0 data.table_1.10.4 bit64_0.9-5 tabplot_1.3-2 ffbase_0.12.3 ff_2.2-13 bit_1.1-12 descr_1.1.3 zoo_1.7-14 forcats_0.2.0
[13] testthat_1.0.2 knitr_1.15.1 foreach_1.4.3 scales_0.4.1 viridis_0.3.4 d3heatmap_0.6.1.1 leaflet_1.1.0 highcharter_0.5.0 gridExtra_2.2.1 ggfortify_0.4.1 ggiraphExtra_0.1.0 ggplot2_2.2.1
[25] magrittr_1.5 lubridate_1.6.0 stringr_1.2.0 ineq_0.2-13 DT_0.2 flexdashboard_0.5 extrafont_0.17 HDoutliers_0.15 mclust_5.2.3 FactoMineR_1.35 FNN_1.1 vcdExtra_0.7-0
[37] gnm_1.0-8 vcd_1.4-3 foreign_0.8-67 readxl_0.1.1 uuid_0.1-2 openxlsx_4.0.0
loaded via a namespace (and not attached):
[1] nlme_3.1-131 xts_0.9-7 rprojroot_1.2 tools_3.3.3 backports_1.0.5 R6_2.2.0 DBI_0.6 lazyeval_0.2.0 mgcv_1.8-16 colorspace_1.3-2 nnet_7.3-12
[12] mnormt_1.5-5 compiler_3.3.3 extrafontdb_1.0 flashClust_1.01-2 xml2_1.1.1 officer_0.1.1 labeling_0.3 lmtest_0.9-35 psych_1.6.12 digest_0.6.12 relimp_1.0-5
[23] rmarkdown_1.3 R.utils_2.5.0 ca_0.70 base64enc_0.1-3 htmltools_0.3.5 rvg_0.1.3 htmlwidgets_0.8 TTR_0.23-1 quantmod_0.4-7 shiny_1.0.0 jsonlite_1.3
[34] crosstalk_1.0.0 dplyr_0.5.0 R.oo_1.21.0 rlist_0.4.6.1 leaps_3.0 qvcalc_0.9-0 Matrix_1.2-8 Rcpp_0.12.10 munsell_0.4.3 gdtools_0.1.4 R.methodsS3_1.7.1
[45] scatterplot3d_0.3-38 stringi_1.1.2 MASS_7.3-45 plyr_1.8.4 crayon_1.3.2 lattice_0.20-34 igraph_1.0.1 codetools_0.2-15 reshape2_1.4.2 fastmatch_1.1-0 ggiraph_0.3.2
[56] evaluate_0.10 mycor_0.1 png_0.1-7 httpuv_1.3.3 Rttf2pt1_1.3.4 gtable_0.2.0 purrr_0.2.2 tidyr_0.6.1 assertthat_0.1 mime_0.5 xtable_1.8-2
[67] broom_0.4.2 tibble_1.2 cluster_2.0.6