Hi! I have a question about how to subset data to then achieve an average of a specific group of numbers.
block<-c('T1', 'T1', 'T1', 'T1','T2', 'T2', 'T2', 'T2') plot<-c('1', '1', '1', '1','1', '1', '1', '1') subplot<-c('NO', 'NI', 'EO', 'EI','NO', 'NI', 'EO', 'EI') data1<-c(0,2,4,2,3,5,2,4) data2<-c(1,1,1,7,2,2,3,1) orig.DF<-data.frame(block, plot, subplot, data1, data2)
So I have block, plot, and subplot as my three levels. I want to have a single average for each plot. So I need to combine the data for each subplot to have a single average value for data1 and data2 that represent a block and plot.
I want a dataframe that looks like this:
block plot data1 data2
1 1 2 2.5
2 1 3.5 2
I can probably use the subset or aggregate functions but I'm not sure how to syntax this!
Please let me know if you need any additional information! Thank you!