October 2017
Beginner to intermediate
572 pages
26h 1m
English
If you need to compute an aggregated summary of statistics against data in different groups, you can use the aggregate and reshape functions to compute the summary statistics of data subsets:
> aggregate(x=iris[,1:4],by=list(iris$Species),FUN=mean)
> library(reshape)
> iris.melt <- melt(iris,id='Species')
> cast(Species~variable,data=iris.melt,mean,
subset=Species %in% c('setosa','versicolor'),
margins='grand_row')
For information on reshape and aggregate, refer to the help documents by using ?reshape or ?aggregate.
Read now
Unlock full access