#STEP 1: READ DATA FILES archaeo_meas <- read.csv("https://docs.google.com/spreadsheets/d/1cw4Bfm8Ic5oOv97NT_iPvNUOIT93zp9VTJcfLHFXX0g/export?gid=0&format=csv") reef_ct <- read.csv("https://docs.google.com/spreadsheets/d/1XRQB4c_4A3wr9mqxkyIGSHLtGxJwjdthb9nUc6DkwPA/export?gid=0&format=csv") #END OF STEP 1 #STEP 2: SUMMARIZE RESULTS cavity_size <- sapply(split(archaeo_meas,archaeo_meas$level), function(x) median(x$cavity_diam/x$total_diam, na.rm=T)) cavity_size <- round(cavity_size, 3) archaeo_abund <- sapply(split(reef_ct,reef_ct$level), function(x) median(apply(x[,2:4],1,function(y) y[1]/sum(y)), na.rm=T)) archaeo_abund <- round(archaeo_abund, 3) #STEP 3: PLOT CENTRAL CAVITY SIZES #this is a box-and-whisker plot #the thick line is the median value (the average) #the box ranges between the quartiles (i.e., 25% of the values are below and another 25% are above) #the lines are the total range, with some outliers marked with dots cavity.plot <- function() { plot(archaeo_meas$level, archaeo_meas$cavity_diam/archaeo_meas$total_diam, xlab="Site", ylab="Central cavity diameter/Total diameter") text(c(1, 2, 3), cavity_size+0.02, cavity_size) } #END OF STEP 2 #STEP 3: PLOT REEF COMPONENTS reef.plot <- function() { plot(reef_ct$level, apply(reef_ct[,2:4], 1, function(x) x[1]/sum(x)), xlab="Site", ylab="Proportion archaeocyaths") text(c(1, 2, 3), archaeo_abund+0.02, archaeo_abund) } #END OF STEP 3