1. Setworking directory
setwd("D:/R_working/subhan_gases_data")2. Import the data file
data_flux<-read.csv("all_data1.csv",na="***")3. Data frame
data_flux <- data.frame (data_flux)4. check data structure
str(data_flux)5. Convert your treatment variables into factor
data_flux <- within(data_flux, {
day <- as.numeric(day )
repliction <- factor(repliction)
Fertilizer.type <- factor(Fertilizer.type)
Biochar <- factor(Biochar)
})6. View again data structure
str(data_flux)7. Re-arrange level of a factor
data_flux$Fertilizer.type<- factor(data_flux$Fertilizer.type, levels=levels(data_flux$Fertilizer.type)[c(2,4,3,1)])7. Calculate mean
mean_flux <- aggregate(.~Date+Fertilizer.type+Biochar, FUN="mean", data=data_flux)8.Calculate the standard deviation
sd_flux <-aggregate(.~Date+Fertilizer.type+Biochar, FUN="sd", data=data_flux)9. Save your sessions
save(list = ls(all=TRUE), file= "D:/R_working/subhan_gases_data//session1")
load(file= "D:/R_working/subhan_gases_data/session1")
No comments:
Post a Comment