## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'agricolae'
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'slackr'
ggplot2のaes(group)内で処理をする (メモ
aes(group = paste(グループ化したい変数1, 変数2))
とすると楽
data_yield <-
data_frame(
ExptID = rep(letters[1:3], each = 10),
Water = rep(c(0.1, 1), times = 15),
Fertilizer = rep(1:10, times = 3),
Yield = Fertilizer * 5 + Water * 10 + rnorm(30, 0, 1)
)
data_yield %>%
kable
ExptID | Water | Fertilizer | Yield |
---|---|---|---|
a | 0.1 | 1 | 5.985410 |
a | 1.0 | 2 | 21.218895 |
a | 0.1 | 3 | 15.631830 |
a | 1.0 | 4 | 31.167487 |
a | 0.1 | 5 | 23.802834 |
a | 1.0 | 6 | 39.170784 |
a | 0.1 | 7 | 36.628281 |
a | 1.0 | 8 | 47.842506 |
a | 0.1 | 9 | 45.016495 |
a | 1.0 | 10 | 60.352300 |
b | 0.1 | 1 | 7.135349 |
b | 1.0 | 2 | 19.083608 |
b | 0.1 | 3 | 15.270552 |
b | 1.0 | 4 | 30.923255 |
b | 0.1 | 5 | 26.639781 |
b | 1.0 | 6 | 41.311815 |
b | 0.1 | 7 | 37.034801 |
b | 1.0 | 8 | 48.815481 |
b | 0.1 | 9 | 44.428771 |
b | 1.0 | 10 | 60.411643 |
c | 0.1 | 1 | 5.649422 |
c | 1.0 | 2 | 19.877400 |
c | 0.1 | 3 | 15.371708 |
c | 1.0 | 4 | 30.367736 |
c | 0.1 | 5 | 25.606334 |
c | 1.0 | 6 | 41.849246 |
c | 0.1 | 7 | 36.137048 |
c | 1.0 | 8 | 50.867419 |
c | 0.1 | 9 | 46.259232 |
c | 1.0 | 10 | 58.442981 |
data_yield %>%
ggplot(aes(x = Fertilizer, y = Yield, col = ExptID, group = Water)) +
geom_point() +
geom_line()
data_yield %>%
ggplot(aes(x = Fertilizer, y = Yield, col = ExptID, group = ExptID)) +
geom_point() +
geom_line()
# こうじゃなくて
data_yield %>%
mutate(Groups = paste0(ExptID, "_", Water)) %>%
ggplot(aes(x = Fertilizer, y = Yield, col = ExptID, group = Groups)) +
geom_point() +
geom_line()
# こう
data_yield %>%
ggplot(aes(x = Fertilizer, y = Yield, col = ExptID, group = paste0(ExptID, Water))) +
geom_point() +
geom_line()
session_info()
## setting value
## version R version 3.5.0 (2018-04-23)
## system x86_64, darwin15.6.0
## ui X11
## language (EN)
## collate en_US.UTF-8
## tz Australia/Brisbane
## date 2018-05-16
##
## package * version date source
## assertthat 0.2.0 2017-04-11 CRAN (R 3.5.0)
## backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
## base * 3.5.0 2018-04-24 local
## bindr 0.1.1 2018-03-13 CRAN (R 3.5.0)
## bindrcpp * 0.2.2 2018-03-29 CRAN (R 3.5.0)
## bitops * 1.0-6 2013-08-17 CRAN (R 3.5.0)
## blogdown 0.6 2018-04-18 CRAN (R 3.5.0)
## bookdown 0.7 2018-02-18 CRAN (R 3.5.0)
## codetools 0.2-15 2016-10-05 CRAN (R 3.5.0)
## colorspace 1.3-2 2016-12-14 CRAN (R 3.5.0)
## compiler 3.5.0 2018-04-24 local
## data.table * 1.10.4-3 2017-10-27 CRAN (R 3.5.0)
## datasets * 3.5.0 2018-04-24 local
## devtools * 1.13.5 2018-02-18 CRAN (R 3.5.0)
## digest 0.6.15 2018-01-28 CRAN (R 3.5.0)
## doParallel 1.0.11 2017-09-28 CRAN (R 3.5.0)
## doRNG 1.6.6 2017-04-10 CRAN (R 3.5.0)
## dplyr * 0.7.4 2017-09-28 CRAN (R 3.5.0)
## evaluate 0.10.1 2017-06-24 CRAN (R 3.5.0)
## foreach * 1.4.4 2017-12-12 CRAN (R 3.5.0)
## ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.5.0)
## glue 1.2.0 2017-10-29 CRAN (R 3.5.0)
## graphics * 3.5.0 2018-04-24 local
## grDevices * 3.5.0 2018-04-24 local
## grid * 3.5.0 2018-04-24 local
## gridExtra * 2.3 2017-09-09 CRAN (R 3.5.0)
## gtable * 0.2.0 2016-02-26 CRAN (R 3.5.0)
## highr 0.6 2016-05-09 CRAN (R 3.5.0)
## htmltools 0.3.6 2017-04-28 CRAN (R 3.5.0)
## iterators 1.0.9 2017-12-12 CRAN (R 3.5.0)
## knitr * 1.20 2018-02-20 CRAN (R 3.5.0)
## labeling 0.3 2014-08-23 CRAN (R 3.5.0)
## lazyeval 0.2.1 2017-10-29 CRAN (R 3.5.0)
## lubridate * 1.7.4 2018-04-11 CRAN (R 3.5.0)
## magrittr * 1.5 2014-11-22 CRAN (R 3.5.0)
## MASS * 7.3-49 2018-02-23 CRAN (R 3.5.0)
## memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
## methods * 3.5.0 2018-04-24 local
## munsell 0.4.3 2016-02-13 CRAN (R 3.5.0)
## parallel 3.5.0 2018-04-24 local
## pforeach * 1.3 2018-04-25 Github (hoxo-m/pforeach@2c44f3b)
## pillar 1.2.1 2018-02-27 CRAN (R 3.5.0)
## pkgconfig 2.0.1 2017-03-21 CRAN (R 3.5.0)
## pkgmaker 0.22 2014-05-14 CRAN (R 3.5.0)
## plyr * 1.8.4 2016-06-08 CRAN (R 3.5.0)
## purrr 0.2.4 2017-10-18 CRAN (R 3.5.0)
## R6 2.2.2 2017-06-17 CRAN (R 3.5.0)
## RColorBrewer * 1.1-2 2014-12-07 CRAN (R 3.5.0)
## Rcpp 0.12.16 2018-03-13 CRAN (R 3.5.0)
## RCurl * 1.95-4.10 2018-01-04 CRAN (R 3.5.0)
## registry 0.5 2017-12-03 CRAN (R 3.5.0)
## reshape2 * 1.4.3 2017-12-11 CRAN (R 3.5.0)
## rlang 0.2.0 2018-02-20 CRAN (R 3.5.0)
## rmarkdown 1.9 2018-03-01 CRAN (R 3.5.0)
## rngtools 1.2.4 2014-03-06 CRAN (R 3.5.0)
## rprojroot 1.3-2 2018-01-03 CRAN (R 3.5.0)
## scales * 0.5.0 2017-08-24 CRAN (R 3.5.0)
## stats * 3.5.0 2018-04-24 local
## stringi 1.2.2 2018-05-02 cran (@1.2.2)
## stringr * 1.3.1 2018-05-10 cran (@1.3.1)
## tibble 1.4.2 2018-01-22 CRAN (R 3.5.0)
## tidyr * 0.8.0 2018-01-29 CRAN (R 3.5.0)
## tools 3.5.0 2018-04-24 local
## utils * 3.5.0 2018-04-24 local
## withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
## xfun 0.1 2018-01-22 CRAN (R 3.5.0)
## xtable 1.8-2 2016-02-05 CRAN (R 3.5.0)
## yaml 2.1.18 2018-03-08 CRAN (R 3.5.0)