library(agricolae)
library(readr)
TR_time_rank <- read_csv("TR_time_rank.csv")
## Parsed with column specification:
## cols(
##   ranking = col_character(),
##   class = col_character(),
##   entry = col_double(),
##   name = col_character(),
##   time = col_character(),
##   rep = col_double(),
##   average = col_double()
## )
View(TR_time_rank)
names(TR_time_rank)
## [1] "ranking" "class"   "entry"   "name"    "time"    "rep"     "average"
attach(TR_time_rank)
library(ggplot2)
library(maps)
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)
entry=as.factor(entry)
ranking=as.factor(ranking)
name=as.factor(name)
class=as.factor(class)
time=as.factor(time)
tim=factor(time,levels = c("9_11am",
"1_3pm","5pm"),ordered=TRUE)
stat_box_data <- function(average, upper_limit = max(average)*1.5) {
  return( 
    data.frame(
      y = 75,
      label = paste('N =', length(average), '\n',
                    'Mean =', round(mean(average), 0), '\n')
    )
  )
}
theme_set(theme_gray(base_size =12))
ggplot(TR_time_rank, aes(x = class, y = average,colour=ranking)) + 
    geom_boxplot(size=0.8,varwidth = FALSE) + 
    geom_point(data = TR_time_rank, aes(y = mean(average))) +
    geom_line(data = TR_time_rank, aes(y =mean(average), group = ranking))+ylab("TR") + 
  xlab("Class")+theme_classic()+theme(legend.position = c(0.85, 0.65))+stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = stat_box_data, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3,
    color="black"
  )

theme_set(theme_gray(base_size =12))
ggplot(TR_time_rank, aes(x = tim, y = average)) + 
    geom_boxplot(size=0.7,varwidth = TRUE,fill=c("grey","gold","green","grey","gold","green")) + 
    geom_point(data = TR_time_rank, aes(y = mean(average))) +
    geom_line(data = TR_time_rank, aes(y =mean(average), group = ranking))+ylab("TR") + 
  xlab("Time Interval")+theme(legend.position = c(0.85, 0.85))+facet_wrap(.~ranking)+theme_classic()+stat_summary(fun.y=mean, geom="point", shape=10, size=2, color="blue", fill="red")+
  stat_summary(
    fun.data = stat_box_data, 
    geom = "text", 
    hjust = 0.5,
    vjust = 0.9,
    size=3
  )

theme_set(theme_dark(base_size =12))
ggplot(TR_time_rank, aes(x = entry, y = average)) + 
    geom_boxplot(size=1.2,varwidth = TRUE) + 
    geom_point(data = TR_time_rank, aes(y = mean(average))) +
    geom_line(data = TR_time_rank, aes(y =mean(average), group = ranking))+ylab("TR") + 
  xlab("Hybrid (Entry)")+theme(legend.position = c(0.85, 0.85))+facet_wrap(.~ranking)
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?

theme_set(theme_gray(base_size =7))
ggplot(TR_time_rank, aes(x = entry, y = average)) + 
    geom_boxplot(size=1.2,varwidth = TRUE) + 
    geom_point(data = TR_time_rank, aes(y = mean(average))) +
    geom_line(data = TR_time_rank, aes(y =mean(average), group = ranking))+ylab("TR") + 
  xlab("Hybrid (Entry)")+theme(legend.position = c(0.85, 0.85))+facet_wrap(.~name)
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?

# violin plots of Country maize grain yields 
theme_set(theme_gray(base_size =10))
m <- ggplot(data=TR_time_rank,aes(x=ranking, y=average))
m + geom_violin(size=1.3,shape=8) + geom_boxplot(width=.3, outlier.size=0,fill=c("red","yellow"))+ylab("TR") + xlab("Ranking")
## Warning: Ignoring unknown parameters: shape

# violin plots of Country maize grain yields 
theme_set(theme_gray(base_size =10))
m <- ggplot(data=TR_time_rank,aes(x=tim, y=average,color=ranking))
m + geom_violin(size=1,shape=8) + geom_boxplot(width=.1, outlier.size=0)+ylab("TR") + xlab("Time Interval")
## Warning: Ignoring unknown parameters: shape