I have used the aggregate function to get a summary of results based on their collection location. The summary returns 3 obs. of 2 variables. One variable is the group name, one is the summary statistic per group.
How do I get R to view each column (Group, min, 1st quartile, median, etc.) as unique in my data frame? Ultimately I'd like this to be 3 obs. of 7 variables, one for each column. OR I'd like to know how to cleanly get min, median, and max by Location. Thanks!
Result <- c(1,1,2,100,50,30,45,20, 10, 8)
Location <- c("Alpha", "Beta", "Gamma", "Alpha", "Beta", "Gamma", "Alpha", "Beta", "Gamma", "Alpha")
df <- data.frame(Result, Location)
head(df)
Agg <- aggregate(df$Result, list(df$Location), summary)
head(Agg)
Group.1 x.Min. x.1st Qu. x.Median x.Mean x.3rd Qu. x.Max.
1 Alpha 1.00 6.25 26.50 38.50 58.75 100.00
2 Beta 1.00 10.50 20.00 23.67 35.00 50.00
3 Gamma 2.00 6.00 10.00 14.00 20.00 30.00