#CHEATGRASS/FIRE TIEE MODULE #R script #set your working directory to the folder where you saved this file on your computer setwd("/Volumes/homes/CheatfireDataACTIVE/Analysis/MODISba_play/TIEE") #read table into R #you will have to save the excel sheet of data called "Whisenent 1990 data" as just a .csv file cdata <- read.table("data_whisenant1990.csv", header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE, stringsAsFactors = F) cdata ############################ #1. Linear regression model of fire frequency as a function of fine fuel frequency #do an xy plot of the data plot(fire_freq~fuel_cover, data=cdata) #fit a best-fit line through the points of data abline(lm(fire_freq~fuel_cover, data=cdata)) #conduct a linear regression model m1 <- lm(fire_freq~fuel_cover, data=cdata) #the summary call gives a summary of the model fit #in this case the shape of the line follows this function: # y = mx + b # y = 0.0086x - 0.28; Adjusted R-squared = 0.86 summary(m1) ############################ #2. Box plots showing the mean (or average) with upper and lower extremes of the data #Mean fine fuel frequency where cheatgrass is (y) and is not (n) the dominant grass bwplot(fuel_cover~cheat_dom, data=cdata, main="Boxplot 1", xlab="Bromus tectorum Dominance", ylab="Fine Fuel Frequency (%)") #Mean fine fuel quantity where cheatgrass is (y) and is not (n) the dominant grass bwplot(fuel_mass~cheat_dom, data=cdata, main="Boxplot 2", xlab="Bromus tectorum Dominance", ylab="Fine Fuel Quantity (lb/acre)") #calculate median and mean values #subset data into two parts based on cheatgrass dominance bty <- subset(cdata, cdata$cheat_dom == "y") btn <- subset(cdata, cdata$cheat_dom == "n") #Median and Mean values for fine fuel frequency (Boxplot 1) median(bty$fuel_cover) median(btn$fuel_cover) mean(bty$fuel_cover) mean(btn$fuel_cover) #Median and Mean values for fine fuel quantity (Boxplot 2) median(bty$fuel_mass) median(btn$fuel_mass) mean(bty$fuel_mass) mean(btn$fuel_mass) #Mean fire frequency where cheatgrass is (y) and is not (n) the dominant grass bwplot(fire_freq~cheat_dom, data=cdata, main="Boxplot 3", xlab="Bromus tectorum Dominance", ylab="Fire Frequency (fires/year)")