#######################Calculation of 4,096 estimates based on permuations of max and min breeding data for the thrre gamebird species released##################### a <-c("1023036") ##No of pheasants in APHA breeding b <- c("0.875", "0.90") ##Pheas/Mall Polygyny rate c <- c("40", "45") ##Pheas egg production d <- c("0.85", "0.95") ##Pheas fertility e <- c("0.55", "0.7") ##Pheas hatchability f <- c("0.97", "0.9") ##Pheas chick surv g <- c("43677") ##No of Mall in APHA breeding h <- c("0.875", "0.90") ##Pheas/Mall Polygyny rate i <- c("41") ##Mall egg production j <- c("0.99") ##Mall fert k <- c("0.71") ##Mall hatchability l <- c("0.97", "0.9") ##Pheas chick surv m <- c("313945") ##No of RLP in APHA breeding n <- c("0.5") ##RLP polygyny o <- c("39.5") ##RLP egg production p <- c("0.59") ##RLP hatchability (inc fert) q <- c("0.97", "0.9") ##Pheas chick surv r <- c("28248773") ##DEFRA import pheas eggs s <- c("0.85", "0.95") ##Pheas fertility t <- c("0.55", "0.7") ##Pheas hatchability u <- c("0.97", "0.9") ##Pheas chick surv v <- c("4972945") ##DEFRA import pheas & RLP chicks w <- c("0.97", "0.9") ##Pheas chick surv tab <- expand.grid(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) tab write.csv(tab, "XXXXXXXXXXXX\\chickprod.csv", row.names=FALSE) ##Estimates were then generated by: (a*b*c*d*e*f) + (g*h*i*j*k*l) + (m*n*o*p*q) + (r*s*t*u) + (v*w) #####################Generating violin plots########################## rm(list=ls()) setwd ("XXXXXXXXXX\\How many gamebirds released") library(ggplot2) all_data <- read.csv("released_R_data.csv", header = T) head(all_data) # Convert the variable Categories from a numeric to a factor variable all_data$Category <- as.factor(all_data$Category) head(all_data) # Basic violin plot of data p <- ggplot(all_data, aes(x=Category, y=Tot_released, na.rm = TRUE)) + geom_violin(trim=FALSE, fill="gray") + geom_hline(yintercept=43.2, linetype="dashed", color = "red") + labs(x="Estimation Method", y = "Number of gamebirds released (millions)") + theme(text = element_text(size=15), axis.text.x = element_text(angle=90, hjust=1), panel.background = element_blank(), panel.border = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.line = element_line(colour = "black")) p # violin plot with dot plot p1 <-p + geom_jitter(shape=16, position=position_jitter(0.2)) # violin plot with mean points p2 <- p1 + stat_summary(fun.y=mean, geom="point", size=4, color="red") p2