#Upload the "monkey_cortisol" dataset into R cortisol_data <- read.csv ("monkey_cortisol.csv", header = T, stringsAsFactors = F) #Change the headers from "Hair_cortisol_concentration" to "hcc" colnames (cortisol_data)[colnames(cortisol_data)=="Hair_cortisol_concentration"] <- "hcc" #Change the sex labels from "0" to "am" (i.e., adult male) and from "1" to "af" (i.e., adult female) cortisol_data["Sex"] [cortisol_data["Sex"] == 0] <- "am" cortisol_data["Sex"] [cortisol_data["Sex"] == 1] <- "af" #Change Matriline data from number to character cortisol_data$Matriline <- as.character(cortisol_data$Matriline) #Create a box plot that contains median differences between the three matrilines split by adult males and females p <- ggplot (cortisol_data, aes (x = Matriline, y = hcc, fill = Sex)) + geom_boxplot (position = "dodge") #Add the following axis labels, graph title, and legend keys w<- p + ggtitle("Difference in hair cortisol concentration \n between males and females")+ xlab("Matriline") + ylab("Hair Cortisol Concentration (pg/mg)") + scale_fill_discrete(labels = c("Adult \n females", "Adult \n males")) #Graph title needs to be placed in the middle and its size needs to be 30. The labels of both x and y axis need to be 15 and need to be located in the middle of the axis. Legend title needs to be 20 and legend key needs to be 15. Panel background needs to be white/transparent, while axis line needs to be black and with size of 0.4 c<- w + theme(plot.title = element_text(color = "black", size = 30, hjust = .5), axis.text = element_text(color = "black", size = 15, hjust = .5, vjust = .5, face = "plain"), axis.title= element_text(color = "black", size = 15, vjust =3), panel.background = element_rect(fill = "transparent",colour = NA), axis.line = element_line(color="black", size = .2), legend.title = element_text(color = "black", size = 20), legend.text = element_text(color = "black", size = 15, margin = margin(t=6))) #Create the code to produce the segments and text that indicate a significant difference between sexes in matriline 1 but not in matriline 3 and 4 as per the following graph c + annotate ("segment", x = (0.75), xend = (1.20), y = 550, yend = 550 )+ annotate ("segment", x = (1.75), xend = (2.20), y = 550, yend = 550) + annotate ("segment", x = (2.75), xend = (3.20), y = 550, yend = 550) + annotate ("text", x = 0.97, y =560, label ="***", size = 5) + annotate ("text", x = 1.97, y = 565, label ='ns', size = 5) + annotate ("text", x = 2.97, y = 565, label = "ns", size = 5)