How is it possible to group rows of a matrix or a data frame by the same values of the first column? 1 14331 453452 653 3762 45 1 1433,453452 45, 653 376 Thanks Carol [[alternative HTML version deleted]]
Possibly aggregate(), but you posted in HTML so your data were mangled. Please use dput(), post in plain text, and try to explain more clearly what you want the result to look like. Sarah On Wed, Mar 9, 2016 at 7:09 AM, carol white via R-help <r-help at r-project.org> wrote:> How is it possible to group rows of a matrix or a data frame by the same values of the first column? > 1 14331 453452 653 3762 45 > > 1 1433,453452 45, 653 376 > Thanks > > Carol > > [[alternative HTML version deleted]] > > ___________________
What should be FUN in aggregate as no function like mean, sum etc will be applied Carol On Wednesday, March 9, 2016 1:59 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote: Possibly aggregate(), but you posted in HTML so your data were mangled. Please use dput(), post in plain text, and try to explain more clearly what you want the result to look like. Sarah On Wed, Mar 9, 2016 at 7:09 AM, carol white via R-help <r-help at r-project.org> wrote:> How is it possible to group rows of a matrix or a data frame by the same values of the first column? > 1 14331 453452 653 3762 45 > > 1 1433,453452 45, 653 376 > Thanks > > Carol > >? ? ? ? [[alternative HTML version deleted]] > > ___________________[[alternative HTML version deleted]]
> 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}}