[R] group by rows
S Ellison
S.Ellison at LGCGroup.com
Wed Mar 9 14:52:49 CET 2016
> How is it possible to group rows of a matrix or a data frame by the same values
> of the first column?
If you mean _group_ as in SQL GROUP BY, use aggregate() with a count or summary statistic.
If you mean _sort_, just to get similar values close together, use order()
For example, to sort by the first column of a matrix mm:
oo <- order(mm[,1])
mm[oo,]
order() also takes multiple sort fields so can sort by several columns simultaneously (eg sort by first column and within that by third column etc).
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
More information about the R-help
mailing list