我是不是遗漏了什么?冲积层包中的示例给出了以下错误:
> library(ggalluvial)
> ggplot(as.data.frame(Titanic),
+ aes(weight = Freq,
+ axis1 = Class, axis2 = Sex, axis3 = Age,
+ fill = Survived)) +
+ geom_alluvium() +
+ scale_x_continuous(breaks = 1:3, labels = c("Class", "Sex", "Age"))
Error: Invalid column specification更新2:按照DanHall的要求:
sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggalluvial_0.6.0 ggthemes_3.4.0 alluvial_0.1-2 dplyr_0.5.0 purrr_0.2.2 readr_0.2.2 tidyr_0.6.1
[8] tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.1.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 compiler_3.4.3 plyr_1.8.4 base64enc_0.1-3 forcats_0.2.0 tools_3.4.3 digest_0.6.12
[8] evaluate_0.10.1 jsonlite_1.5 lubridate_1.5.6 gtable_0.2.0 nlme_3.1-128 lattice_0.20-33 rlang_0.1.4
[15] psych_1.6.4 DBI_0.6 yaml_2.1.14 parallel_3.4.3 haven_1.0.0 stringr_1.2.0 httr_1.3.1
[22] knitr_1.19 xml2_1.1.1 hms_0.3 rprojroot_1.2 grid_3.4.3 R6_2.2.2 readxl_0.1.1
[29] rmarkdown_1.8 reshape2_1.4.2 modelr_0.1.0 magrittr_1.5 backports_1.1.1 htmltools_0.3.6 scales_0.5.0
[36] rsconnect_0.8.5 assertthat_0.1 mnormt_1.5-4 rvest_0.3.2 colorspace_1.3-2 labeling_0.3 stringi_1.1.6
[43] lazyeval_0.2.1 munsell_0.4.3 broom_0.4.1 发布于 2018-03-18 00:49:40
如下所示,此代码在另一台计算机上工作。当对其他人起作用的东西不适合您时,运行update.packages()并按照说明更新您可能已经安装的过时的包可能是有用的。这才是解决问题的办法。
它在我的机器上工作如下:
ggplot(as.data.frame(Titanic),
aes(weight = Freq,
axis1 = Class, axis2 = Sex, axis3 = Age,
fill = Survived)) +
geom_alluvium() +
scale_x_continuous(breaks = 1:3, labels = c("Class", "Sex", "Age"))

它在调用example(geom_alluvium, package = "ggalluvial")时也能工作。
下面是另一个用法示例(摘自vignette)。
ggplot(as.data.frame(Titanic),
aes(weight = Freq,
axis1 = Survived, axis2 = Sex, axis3 = Class)) +
geom_alluvium(aes(fill = Class),
width = 0, knot.pos = 0, reverse = FALSE) +
guides(fill = FALSE) +
geom_stratum(width = 1/8, reverse = FALSE) +
geom_text(stat = "stratum", label.strata = TRUE, reverse = FALSE) +
scale_x_continuous(breaks = 1:3, labels = c("Survived", "Sex", "Class")) +
coord_flip() +
ggtitle("Titanic survival by class and sex")https://stackoverflow.com/questions/49343351
复制相似问题