library(readr)
GMCCoffstation <- read_csv("GMCCoffstation.csv")
## Parsed with column specification:
## cols(
##   season = col_double(),
##   ward = col_double(),
##   farmer = col_character(),
##   crop = col_character(),
##   treat = col_character(),
##   rep = col_double(),
##   biomass = col_double(),
##   `biomass/1000` = col_double(),
##   grain = col_double(),
##   `grain/1000` = col_double()
## )
View(GMCCoffstation)
attach(GMCCoffstation)
season=as.numeric(season)
ward=as.factor(ward)
farmer=as.factor(farmer)
treat=as.factor(treat)
rep=as.factor(rep)
library(ggplot2)
library(plyr)
library(maps)
## 
## Attaching package: 'maps'
## The following object is masked from 'package:plyr':
## 
##     ozone
library(ggalt)
## Registered S3 methods overwritten by 'ggalt':
##   method                  from   
##   grid.draw.absoluteGrob  ggplot2
##   grobHeight.absoluteGrob ggplot2
##   grobWidth.absoluteGrob  ggplot2
##   grobX.absoluteGrob      ggplot2
##   grobY.absoluteGrob      ggplot2
library(extrafontdb)
library(MASS)
library(pscl)
## Classes and Methods for R developed in the
## Political Science Computational Laboratory
## Department of Political Science
## Stanford University
## Simon Jackman
## hurdle and zeroinfl functions by Achim Zeileis
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library(gridExtra)
library(repr) ### adjusting the length and width of your plot
library(beanplot)
library("devtools")
## Loading required package: usethis
library("yarrr")
## Loading required package: jpeg
## Loading required package: BayesFactor
## Loading required package: coda
## Loading required package: Matrix
## ************
## Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
## 
## Type BFManual() to open the manual.
## ************
## Loading required package: circlize
## ========================================
## circlize version 0.4.6
## CRAN page: https://cran.r-project.org/package=circlize
## Github page: https://github.com/jokergoo/circlize
## Documentation: http://jokergoo.github.io/circlize_book/book/
## 
## If you use it in published research, please cite:
## Gu, Z. circlize implements and enhances circular visualization 
##   in R. Bioinformatics 2014.
## ========================================
## yarrr v0.1.5. Citation info at citation('yarrr'). Package guide at yarrr.guide()
## Email me at Nathaniel.D.Phillips.is@gmail.com
## 
## Attaching package: 'yarrr'
## The following object is masked from 'package:ggplot2':
## 
##     diamonds
library(agricolae)
library(easynls)
library(MVN)
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
## sROC 0.1-2 loaded
library(lme4)
## Registered S3 methods overwritten by 'lme4':
##   method                          from
##   cooks.distance.influence.merMod car 
##   influence.merMod                car 
##   dfbeta.influence.merMod         car 
##   dfbetas.influence.merMod        car
library(ggsignif)
library(ggpubr)
## Loading required package: magrittr
## 
## Attaching package: 'ggpubr'
## The following object is masked from 'package:plyr':
## 
##     mutate
library(tidyverse)
## -- Attaching packages --------------------------------------------------------- tidyverse 1.2.1 --
## v tibble  2.1.3     v dplyr   0.8.3
## v tidyr   0.8.3     v stringr 1.4.0
## v purrr   0.3.2     v forcats 0.4.0
## -- Conflicts ------------------------------------------------------------ tidyverse_conflicts() --
## x psych::%+%()       masks ggplot2::%+%()
## x psych::alpha()     masks ggplot2::alpha()
## x dplyr::arrange()   masks plyr::arrange()
## x dplyr::combine()   masks gridExtra::combine()
## x purrr::compact()   masks plyr::compact()
## x dplyr::count()     masks plyr::count()
## x tidyr::expand()    masks Matrix::expand()
## x tidyr::extract()   masks magrittr::extract()
## x dplyr::failwith()  masks plyr::failwith()
## x dplyr::filter()    masks stats::filter()
## x dplyr::id()        masks plyr::id()
## x dplyr::lag()       masks stats::lag()
## x purrr::map()       masks maps::map()
## x dplyr::mutate()    masks ggpubr::mutate(), plyr::mutate()
## x dplyr::rename()    masks plyr::rename()
## x dplyr::select()    masks MASS::select()
## x purrr::set_names() masks magrittr::set_names()
## x dplyr::summarise() masks plyr::summarise()
## x dplyr::summarize() masks plyr::summarize()
library(ggalluvial)
#################density plots#################
####################treat##############
ggplot(data = GMCCoffstation, mapping = aes(x = grain/1000, fill = treat)) + geom_density(alpha = 0.5)

ggplot(data = GMCCoffstation, mapping = aes(x = biomass/1000, fill = treat)) + geom_density(alpha = 0.5)

######################ANOVA grain###############
mod<-aov(grain/1000~rep+farmer+ward+season:rep+treat+season+farmer:ward+farmer:treat:ward+season:ward,data=GMCCoffstation)
anova(mod)
## Analysis of Variance Table
## 
## Response: grain/1000
##                    Df  Sum Sq Mean Sq F value    Pr(>F)    
## rep                 1   4.287  4.2872  4.5834  0.033816 *  
## farmer             20 162.584  8.1292  8.6908 < 2.2e-16 ***
## treat               5  26.772  5.3545  5.7244 6.976e-05 ***
## season              1  27.098 27.0982 28.9704 2.612e-07 ***
## rep:season          1   5.067  5.0671  5.4172  0.021208 *  
## ward:season         1   9.128  9.1284  9.7591  0.002123 ** 
## farmer:ward:treat 100  81.343  0.8134  0.8696  0.774441    
## Residuals         158 147.789  0.9354                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(mod)
##                    Df Sum Sq Mean Sq F value   Pr(>F)    
## rep                 1   4.29   4.287   4.583  0.03382 *  
## farmer             20 162.58   8.129   8.691  < 2e-16 ***
## treat               5  26.77   5.354   5.724 6.98e-05 ***
## season              1  27.10  27.098  28.970 2.61e-07 ***
## rep:season          1   5.07   5.067   5.417  0.02121 *  
## ward:season         1   9.13   9.128   9.759  0.00212 ** 
## farmer:ward:treat 100  81.34   0.813   0.870  0.77444    
## Residuals         158 147.79   0.935                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
y<-HSD.test(mod,"treat",group = TRUE)
y
## $statistics
##     MSerror  Df     Mean       CV       MSD
##   0.9353752 158 2.549194 37.93937 0.5695539
## 
## $parameters
##    test name.t ntr StudentizedRange alpha
##   Tukey  treat   6         4.080022  0.05
## 
## $means
##                grain/1000      std  r    Min    Max      Q25     Q50
## COWP_INT         2.505654 1.221901 48 0.3836 6.0609 1.767800 2.54715
## JCKBN_INT        2.418983 1.008070 48 0.2537 4.9269 1.800750 2.36910
## LABLAB_INT       2.418181 1.292090 48 0.4825 6.5697 1.510825 2.39455
## PGPEA_COWP_INT   2.172323 1.112348 48 0.5073 5.1913 1.366975 1.98030
## PGPEA_INT        2.618533 1.249121 48 0.6387 6.0833 1.640575 2.35075
## SOLE_MZ          3.161487 1.525724 48 0.5355 6.6848 2.090525 2.71220
##                     Q75
## COWP_INT       3.162225
## JCKBN_INT      2.917725
## LABLAB_INT     3.011300
## PGPEA_COWP_INT 2.917450
## PGPEA_INT      3.269675
## SOLE_MZ        4.337925
## 
## $comparison
## NULL
## 
## $groups
##                grain/1000 groups
## SOLE_MZ          3.161487      a
## PGPEA_INT        2.618533     ab
## COWP_INT         2.505654      b
## JCKBN_INT        2.418983      b
## LABLAB_INT       2.418181      b
## PGPEA_COWP_INT   2.172323      b
## 
## attr(,"class")
## [1] "group"
x<-HSD.test(mod,"season",group = TRUE)
x
## $statistics
##     MSerror  Df     Mean       CV      MSD
##   0.9353752 158 2.549194 37.93937 0.330285
## 
## $parameters
##    test name.t ntr StudentizedRange alpha
##   Tukey season   3         3.346043  0.05
## 
## $means
##      grain/1000      std  r    Min    Max      Q25     Q50      Q75
## 2017   2.843977 1.366597 96 0.5073 6.6848 1.778000 2.69950 3.754375
## 2018   2.738111 1.132469 96 0.9399 6.1279 1.937725 2.52270 3.135900
## 2019   2.065493 1.172418 96 0.2537 5.1913 1.082975 1.98715 2.822875
## 
## $comparison
## NULL
## 
## $groups
##      grain/1000 groups
## 2017   2.843977      a
## 2018   2.738111      a
## 2019   2.065493      b
## 
## attr(,"class")
## [1] "group"
v<-HSD.test(mod,"farmer",group = TRUE)
v
## $statistics
##     MSerror  Df     Mean       CV
##   0.9353752 158 2.549194 37.93937
## 
## $parameters
##    test name.t ntr StudentizedRange alpha
##   Tukey farmer  21         5.135691  0.05
## 
## $means
##              grain/1000       std  r    Min    Max      Q25     Q50
## E. Maresa      2.478561 1.3101922 18 0.7193 4.8348 1.350725 2.46155
## E. Matanda     2.656083 0.5783633 12 1.9428 3.8277 2.065325 2.70585
## E. Pangwa      1.964733 0.6196082 12 0.7998 2.8411 1.651825 2.03390
## E.Matanda      1.806967 0.3775486  6 1.4516 2.3965 1.540900 1.66680
## E.Pangwa       1.079467 0.6002911  6 0.5384 2.2410 0.782175 0.93520
## F. Masango     2.564500 0.4976239 12 1.8057 3.4873 2.283400 2.52735
## F.Masango      3.014800 1.1298755  6 1.7877 5.0675 2.398425 2.86675
## J.Ackchomwe    2.232250 1.0063666  6 0.7087 3.1801 1.579375 2.66785
## J.Mukandi      1.817194 0.6088046 18 0.6928 3.1896 1.472750 1.82325
## Jakuchomwe     3.018175 0.6930173 12 2.0529 4.0870 2.447650 3.13120
## L. Kambarami   2.994161 1.9116775 18 0.4278 6.5697 1.534750 2.83300
## L. Masango     2.057233 0.8364770 12 0.9399 3.9311 1.637875 1.90390
## L.Chikaka      3.431733 1.5742558 18 0.7895 6.0833 2.346600 3.30985
## L.Masango      2.594133 1.0972136  6 0.5355 3.8251 2.626550 2.81755
## M. Masango     1.864950 0.9205786 18 0.5073 4.3559 1.244450 1.59845
## M.Chiweshe     3.637050 0.7211141 18 2.0781 4.9142 3.205700 3.69995
## S. Chikauro    4.383767 1.1424939 18 1.7859 6.6848 3.948925 4.36210
## S. Phiri       2.003256 1.0100625 18 0.2537 3.8888 1.190375 2.30385
## S.Manhembe     2.161783 0.8010658 18 0.7849 3.7792 1.684750 1.83680
## S.Vambe        2.492867 1.5323083 18 0.3836 5.3343 1.031150 2.45080
## T. Matanda     1.772089 0.3872743 18 1.0686 2.5193 1.547150 1.80515
##                   Q75
## E. Maresa    3.237825
## E. Matanda   3.026175
## E. Pangwa    2.446125
## E.Matanda    2.037575
## E.Pangwa     1.055675
## F. Masango   2.775075
## F.Masango    3.160025
## J.Ackchomwe  2.881300
## J.Mukandi    2.190225
## Jakuchomwe   3.481000
## L. Kambarami 4.379225
## L. Masango   2.413125
## L.Chikaka    4.440850
## L.Masango    2.959050
## M. Masango   2.297050
## M.Chiweshe   4.161150
## S. Chikauro  4.985475
## S. Phiri     2.602075
## S.Manhembe   2.398525
## S.Vambe      3.030775
## T. Matanda   1.950200
## 
## $comparison
## NULL
## 
## $groups
##              grain/1000 groups
## S. Chikauro    4.383767      a
## M.Chiweshe     3.637050     ab
## L.Chikaka      3.431733     ab
## Jakuchomwe     3.018175     bc
## F.Masango      3.014800    bcd
## L. Kambarami   2.994161    bcd
## E. Matanda     2.656083    bcd
## L.Masango      2.594133    bcd
## F. Masango     2.564500    bcd
## S.Vambe        2.492867    bcd
## E. Maresa      2.478561    bcd
## J.Ackchomwe    2.232250    bcd
## S.Manhembe     2.161783     cd
## L. Masango     2.057233     cd
## S. Phiri       2.003256     cd
## E. Pangwa      1.964733     cd
## M. Masango     1.864950     cd
## J.Mukandi      1.817194     cd
## E.Matanda      1.806967     cd
## T. Matanda     1.772089     cd
## E.Pangwa       1.079467      d
## 
## attr(,"class")
## [1] "group"
################bar group chart##################
bar.group(y$groups, ylim=c(0,7.5), density=4,border="blue")

bar.group(v$groups, ylim=c(0,7.5), density=4,border="blue")

#####################grain#########################
m<-ggplot(GMCCoffstation, aes(x = treat, y = grain/1000))+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("grey","grey","grey","grey","grey","grey")) + geom_smooth(method=lm)+ ylab("Grain/1000 [kg/ha]") + xlab("treat")+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
m
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

#################facet by season###################
m<-ggplot(GMCCoffstation, aes(x = treat, y = grain/1000))+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey")) + geom_smooth(method=lm)+ ylab("Grain/1000 [kg/ha]") + xlab("treat")+facet_wrap(~season)+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
m
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

#################facet by ward###################
m<-ggplot(GMCCoffstation, aes(x = treat, y = grain/1000))+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey")) + geom_smooth(method=lm)+ ylab("Grain/1000 [kg/ha]") + xlab("treat")+facet_wrap(~ward)+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
m
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

############VIOLIN PLOTS EMBEDDED WITH BOX PLOTS#########
######################grain##################
theme_set(theme_gray(base_size =15))
m <- ggplot(data=GMCCoffstation,aes(x=treat, y=grain/1000))
m + geom_violin(size=1.3,shape=8) + geom_boxplot(width=.2, outlier.size=0,fill=c("grey","grey","grey", "grey","grey", "grey" ))+ylab("Grain [t/ha]") + xlab("treatment")+ theme(axis.title = element_text(size=20, face="bold"), axis.text.x = element_text(size=12, face="bold", angle = 90, hjust = 1), axis.text.y = element_text(size=16, face="bold"))+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: shape
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

######################ANOVA biomass###############
mod<-aov(biomass/1000~rep+farmer+ward+season:rep+treat+season+farmer:ward+farmer:treat:ward+season:ward,data=GMCCoffstation)
anova(mod)
## Analysis of Variance Table
## 
## Response: biomass/1000
##                    Df  Sum Sq Mean Sq F value    Pr(>F)    
## rep                 1   0.384  0.3836  0.4598  0.498688    
## farmer             20 140.037  7.0019  8.3944 2.365e-16 ***
## treat               5  14.188  2.8377  3.4020  0.006021 ** 
## season              1  20.850 20.8501 24.9969 1.511e-06 ***
## rep:season          1   0.942  0.9421  1.1295  0.289514    
## ward:season         1   0.254  0.2545  0.3051  0.581497    
## farmer:ward:treat 100  48.821  0.4882  0.5853  0.997954    
## Residuals         158 131.789  0.8341                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(mod)
##                    Df Sum Sq Mean Sq F value   Pr(>F)    
## rep                 1   0.38   0.384   0.460  0.49869    
## farmer             20 140.04   7.002   8.394 2.36e-16 ***
## treat               5  14.19   2.838   3.402  0.00602 ** 
## season              1  20.85  20.850  24.997 1.51e-06 ***
## rep:season          1   0.94   0.942   1.129  0.28951    
## ward:season         1   0.25   0.254   0.305  0.58150    
## farmer:ward:treat 100  48.82   0.488   0.585  0.99795    
## Residuals         158 131.79   0.834                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
y<-HSD.test(mod,"treat",group = TRUE)
y
## $statistics
##     MSerror  Df     Mean       CV       MSD
##   0.8341075 158 1.902923 47.99432 0.5378398
## 
## $parameters
##    test name.t ntr StudentizedRange alpha
##   Tukey  treat   6         4.080022  0.05
## 
## $means
##                biomass/1000       std  r    Min    Max      Q25     Q50
## COWP_INT           1.837610 1.0866014 48 0.2418 4.9952 1.058000 1.46705
## JCKBN_INT          1.824623 0.9802905 48 0.1403 4.3502 1.128125 1.87145
## LABLAB_INT         1.842102 1.0706991 48 0.2634 5.2654 1.069000 1.80910
## PGPEA_COWP_INT     1.677294 1.0563908 48 0.4405 5.8978 0.878400 1.51545
## PGPEA_INT          1.855173 1.0519348 48 0.0832 6.1301 1.094125 1.86805
## SOLE_MZ            2.380735 1.3375108 48 0.3843 5.5742 1.464375 1.81830
##                     Q75
## COWP_INT       2.421375
## JCKBN_INT      2.310900
## LABLAB_INT     2.416300
## PGPEA_COWP_INT 2.120300
## PGPEA_INT      2.344275
## SOLE_MZ        3.340725
## 
## $comparison
## NULL
## 
## $groups
##                biomass/1000 groups
## SOLE_MZ            2.380735      a
## PGPEA_INT          1.855173     ab
## LABLAB_INT         1.842102      b
## COWP_INT           1.837610      b
## JCKBN_INT          1.824623      b
## PGPEA_COWP_INT     1.677294      b
## 
## attr(,"class")
## [1] "group"
x<-HSD.test(mod,"season",group = TRUE)
x
## $statistics
##     MSerror  Df     Mean       CV       MSD
##   0.8341075 158 1.902923 47.99432 0.3118939
## 
## $parameters
##    test name.t ntr StudentizedRange alpha
##   Tukey season   3         3.346043  0.05
## 
## $means
##      biomass/1000      std  r    Min    Max      Q25     Q50      Q75
## 2017     2.084092 1.216637 96 0.0832 6.1301 1.273125 1.85950 2.405800
## 2018     1.893193 1.084096 96 0.3843 5.5742 0.966925 1.75705 2.582075
## 2019     1.731484 1.020914 96 0.1403 5.1224 0.817450 1.67530 2.290725
## 
## $comparison
## NULL
## 
## $groups
##      biomass/1000 groups
## 2017     2.084092      a
## 2018     1.893193     ab
## 2019     1.731484      b
## 
## attr(,"class")
## [1] "group"
v<-HSD.test(mod,"farmer",group = TRUE)
v
## $statistics
##     MSerror  Df     Mean       CV
##   0.8341075 158 1.902923 47.99432
## 
## $parameters
##    test name.t ntr StudentizedRange alpha
##   Tukey farmer  21         5.135691  0.05
## 
## $means
##              biomass/1000       std  r    Min    Max      Q25     Q50
## E. Maresa        1.971367 0.9920597 18 0.4808 3.8311 1.396850 1.99995
## E. Matanda       1.613258 0.5156470 12 1.0744 2.5788 1.270200 1.41170
## E. Pangwa        0.998725 0.3695461 12 0.4405 1.7128 0.736975 0.97155
## E.Matanda        2.048550 0.3256923  6 1.6839 2.4702 1.850450 1.93365
## E.Pangwa         0.777800 0.5235298  6 0.4171 1.8161 0.486125 0.60945
## F. Masango       1.516817 0.7424196 12 0.6844 2.7446 0.865600 1.35815
## F.Masango        2.310667 0.7456092  6 1.4317 3.2627 1.754475 2.21165
## J.Ackchomwe      2.956167 0.6949737  6 2.0057 3.7003 2.440575 3.27630
## J.Mukandi        1.241661 0.6919279 18 0.0832 2.5798 0.706275 1.30670
## Jakuchomwe       2.376500 0.8830212 12 0.2589 3.6919 2.156100 2.52015
## L. Kambarami     2.153700 1.4624386 18 0.5905 5.5742 1.085350 1.70740
## L. Masango       1.149950 0.5310115 12 0.5066 2.2907 0.773600 1.07645
## L.Chikaka        2.506017 1.1239497 18 1.2750 5.4052 1.654950 2.26560
## L.Masango        3.073267 0.8677583  6 2.2610 4.3242 2.537825 2.67030
## M. Masango       1.510161 0.8040185 18 0.4743 3.5882 0.899650 1.48950
## M.Chiweshe       2.436094 0.8971487 18 1.5590 4.6560 1.906375 2.03295
## S. Chikauro      3.627361 1.5377831 18 1.3183 6.1301 2.469775 3.28490
## S. Phiri         1.304128 0.8274181 18 0.1403 3.4984 0.754650 1.33900
## S.Manhembe       2.104378 0.6603780 18 0.9728 3.5676 1.735725 2.07055
## S.Vambe          1.464911 0.8229369 18 0.3843 3.3962 0.737150 1.45605
## T. Matanda       1.301339 0.6035300 18 0.5545 2.6747 0.776675 1.26135
##                   Q75
## E. Maresa    2.524075
## E. Matanda   1.818500
## E. Pangwa    1.188600
## E.Matanda    2.318800
## E.Pangwa     0.729625
## F. Masango   2.099500
## F.Masango    2.911075
## J.Ackchomwe  3.306375
## J.Mukandi    1.611800
## Jakuchomwe   2.805000
## L. Kambarami 2.952775
## L. Masango   1.398925
## L.Chikaka    2.887150
## L.Masango    3.682675
## M. Masango   1.886325
## M.Chiweshe   2.418300
## S. Chikauro  5.090600
## S. Phiri     1.615425
## S.Manhembe   2.448375
## S.Vambe      1.942975
## T. Matanda   1.670650
## 
## $comparison
## NULL
## 
## $groups
##              biomass/1000 groups
## S. Chikauro      3.627361      a
## L.Masango        3.073267     ab
## J.Ackchomwe      2.956167    abc
## L.Chikaka        2.506017     bc
## M.Chiweshe       2.436094     bc
## Jakuchomwe       2.376500    bcd
## F.Masango        2.310667   bcde
## L. Kambarami     2.153700   bcde
## S.Manhembe       2.104378   bcde
## E.Matanda        2.048550   bcde
## E. Maresa        1.971367   bcde
## E. Matanda       1.613258   bcde
## F. Masango       1.516817   bcde
## M. Masango       1.510161   bcde
## S.Vambe          1.464911    cde
## S. Phiri         1.304128     de
## T. Matanda       1.301339     de
## J.Mukandi        1.241661     de
## L. Masango       1.149950     de
## E. Pangwa        0.998725      e
## E.Pangwa         0.777800      e
## 
## attr(,"class")
## [1] "group"
################bar group chart##################
bar.group(y$groups, ylim=c(0,7.5), density=4,border="blue")

bar.group(v$groups, ylim=c(0,7.5), density=4,border="blue")

#####################biomass#########################
m<-ggplot(GMCCoffstation, aes(x = treat, y = biomass/1000))+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("grey","grey","grey","grey","grey","grey")) + geom_smooth(method=lm)+ ylab("Biomass/1000 [kg/ha]") + xlab("treat")+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
m
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

#################facet by season###################
m<-ggplot(GMCCoffstation, aes(x = treat, y = biomass/1000))+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey")) + geom_smooth(method=lm)+ ylab("Biomass/1000 [kg/ha]") + xlab("treat")+facet_wrap(~season)+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
m
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

#################facet by ward###################
m<-ggplot(GMCCoffstation, aes(x = treat, y = biomass/1000))+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey","grey")) + geom_smooth(method=lm)+ ylab("Biomass/1000 [kg/ha]") + xlab("treat")+facet_wrap(~ward)+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
m
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

##########new ones box plots biomass##############
ggplot(GMCCoffstation, aes(x=treat, y=biomass/1000)) + geom_boxplot() + geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("gold","gold","gold","gold","gold","gold")) + geom_smooth(method=lm)+ ylab("Biomass/1000 [kg/ha]") + xlab("treat")+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7)) 
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

##########reordered biomass#############
ggplot(GMCCoffstation, aes(x=reorder(treat, biomass/1000, FUN=median), y=biomass/1000)) + geom_boxplot()+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("gold","gold","gold","gold","gold","gold")) + geom_smooth(method=lm)+ ylab("Biomass/1000 [kg/ha]") + xlab("treat")+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7)) 
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

#############################facets biomass################
##########reordered#############
ggplot(GMCCoffstation, aes(x=reorder(treat, biomass/1000, FUN=median), y=biomass/1000)) + geom_boxplot()+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold")) + geom_smooth(method=lm)+ ylab("Biomass/1000 [kg/ha]") + xlab("treat")+facet_wrap(~season)+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

################################
##########reordered#############
ggplot(GMCCoffstation, aes(x=reorder(treat, biomass/1000, FUN=median), y=biomass/1000)) + geom_boxplot()+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold")) + geom_smooth(method=lm)+ ylab("Biomass/1000 [kg/ha]") + xlab("treat")+facet_wrap(~ward)+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

Gmcc_summary <- GMCCoffstation %>% # the names of the new data frame and the data frame to be summarised
  group_by(treat) %>%   # the grouping variable
  summarise(mean_B = mean(biomass/1000),  # calculates the mean of each group
            sd_B = sd(biomass/1000), # calculates the standard deviation of each group
            n_B = n(),  # calculates the sample size per group
            SE_B = sd(biomass/1000)/sqrt(n())) # calculates the standard error of each group


########################
GMCCplot <- ggplot(Gmcc_summary, aes(treat, mean_B)) + 
                   geom_col() +  
                   geom_errorbar(aes(ymin = mean_B - sd_B, ymax = mean_B + sd_B), width=0.2)

GMCCplot + labs(y="Biomass/1000 ± s.d.", x = "Treat") + theme_classic()

Gmcc_summary <- GMCCoffstation %>% # the names of the new data frame and the data frame to be summarised
  group_by(treat) %>%   # the grouping variable
  summarise(mean_G = mean(grain/1000),  # calculates the mean of each group
            sd_G = sd(grain/1000), # calculates the standard deviation of each group
            n_G = n(),  # calculates the sample size per group
            SE_G = sd(grain/1000)/sqrt(n())) # calculates the standard error of each group


########################
GMCCplot <- ggplot(Gmcc_summary, aes(treat, mean_G)) + 
                   geom_col() +  
                   geom_errorbar(aes(ymin = mean_G - sd_G, ymax = mean_G + sd_G), width=0.2)

GMCCplot + labs(y="Grain/1000 ± s.d.", x = "Treat") + theme_classic()

##########new ones box plots grain##############
ggplot(GMCCoffstation, aes(x=treat, y=grain/1000)) + geom_boxplot() + geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("gold","gold","gold","gold","gold","gold")) + geom_smooth(method=lm)+ ylab("Grain/1000 [kg/ha]") + xlab("treat")+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

##########reordered grain#############
ggplot(GMCCoffstation, aes(x=reorder(treat, grain/1000, FUN=median), y=grain/1000)) + geom_boxplot()+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("gold","gold","gold","gold","gold","gold")) + geom_smooth(method=lm)+ ylab("Grain/1000 [kg/ha]") + xlab("treat")+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

#############################facets grain################
##########reordered#############
ggplot(GMCCoffstation, aes(x=reorder(treat, grain/1000, FUN=median), y=grain/1000)) + geom_boxplot()+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold")) + geom_smooth(method=lm)+ ylab("Grain/1000 [kg/ha]") + xlab("treat")+facet_wrap(~season)+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

################################
##########reordered#############
ggplot(GMCCoffstation, aes(x=reorder(treat, grain/1000, FUN=median), y=grain/1000)) + geom_boxplot()+ geom_boxplot(size=0.8,varwidth =FALSE,outlier.colour = "red",outlier.shape = 2, shape=6,fill=c("gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold","gold")) + geom_smooth(method=lm)+ ylab("Grain/1000 [kg/ha]") + xlab("treat")+facet_wrap(~ward)+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

####################VIOLIN PLOTS EMBEDDED WITH BOXPLOTS####################
theme_set(theme_gray(base_size =15))
m <- ggplot(data=GMCCoffstation,aes(x=treat, y=biomass/1000))
m + geom_violin(size=1.3,shape=8) + geom_boxplot(width=.2, outlier.size=0,fill=c("grey","grey","grey", "grey","grey", "grey"))+ylab("Biomass [t/ha]") + xlab("treatment")+ theme(axis.title = element_text(size=20, face="bold"), axis.text.x = element_text(size=12, face="bold", angle = 90, hjust = 1), axis.text.y = element_text(size=16, face="bold"))+
  
  stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: shape
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

################# bar graphs biomass###################
m<-ggplot(GMCCoffstation, aes(x = treat, y = biomass/1000))+ geom_bar(stat="identity", width=0.5, position = "dodge")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 1.8, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 1.8, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 1.7, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 1.9, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 2.4, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
m
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

################# bar graphs grain###################
m<-ggplot(GMCCoffstation, aes(x = treat, y = grain/1000))+ geom_bar(stat="identity", width=0.5, position = "dodge")+
  stat_summary(
    fun.data = GMCCoffstation, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    face="bold"
  )+ theme_classic(base_size = 14)+ ylim(100, 7000)+ theme(axis.text.x = element_text(face="bold", angle = 75, hjust = 1, color="black", 
                                                                                      size=6),
                                                           axis.text.y = element_text(face="bold", color="black", 
                                                                                      size=10))+geom_text(data =GMCCoffstation, x = 1, y = 2.5, label = "b")+geom_text(data =GMCCoffstation, x = 2, y = 2.4, label = "b")+geom_text(data =GMCCoffstation, x = 3, y = 2.4, label = "b")+ geom_text(data =GMCCoffstation, x = 4, y = 2.2, label = "b")+geom_text(data =GMCCoffstation, x = 5, y = 2.6, label = "ab")+geom_text(data =GMCCoffstation, x = 6, y = 3.2, label = "a")+
  ylim(100,7000) + scale_y_continuous(breaks = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7))
## Warning: Ignoring unknown parameters: face
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
m
## Warning: Computation failed in `stat_summary()`:
## object 'fun.data' of mode 'function' was not found

#########aaluvials grain###########
ggplot(GMCCoffstation, aes(kg = grain/1000, axis1 = treat, axis2 = season)) +   
  geom_alluvium(aes(fill = treat), color = "black") + geom_stratum() 

########Add text##############

ggplot(GMCCoffstation, aes(kg = grain/1000, axis1 = treat, axis2 = season)) +  
  geom_alluvium(aes(fill = treat), color = "black") + geom_stratum() +
  geom_text(stat = "stratum", label.strata = TRUE) +
  theme(legend.position = "true",
        axis.text = element_text(size=14))

#########aaluvials biomass###########
ggplot(GMCCoffstation, aes(kg = biomass/1000, axis1 = treat, axis2 = season)) +   
  geom_alluvium(aes(fill = treat), color = "black") + geom_stratum() 

########Add text##############

ggplot(GMCCoffstation, aes(kg = biomass/1000, axis1 = treat, axis2 = season)) +  
  geom_alluvium(aes(fill = treat), color = "black") + geom_stratum() +
  geom_text(stat = "stratum", label.strata = TRUE) +
  theme(legend.position = "true",
        axis.text = element_text(size=14))

ggplot(data = GMCCoffstation, mapping = aes(x = grain/1000, fill = treat)) + geom_density(alpha = 0.5)

mod<-aov(grain/1000~rep+farmer+ward+season:rep+treat+season+farmer:ward+farmer:treat:ward+season:ward,data=GMCCoffstation) anova(mod) ```