I'm new to R and I'm trying to get the mean of a data which is sorted by location and treatment.
My data looks like this:
| Wetland | Treatment | Data | 
|---|---|---|
| Ann | A | 3 | 
| Ann | A | 4 | 
| Ann | B | 2 | 
| ... | ||
| Twin | D | 5 | 
I have 9 locations (Wetland) and 4 treatments (Treatment). Each location has 6 data points per treatment. I am trying to get the means of a location and treatment. Eg:
| Wetland | Treatment | Mean | 
|---|---|---|
| Ann | A | 3.5 | 
| Ann | B | 2 | 
| ... | ||
| Twin | D | 5 | 
I've used
aggregate(PlantData$Data, list(PlantData$Wetland),FUN=mean)
Which gives me the mean of all the data at the location (PlantData$Wetland) but does not separate by treatment.
 
    