Re: [R] group by rows
Hi carol, You could use the "I" function, which will just return what you pass to it. Jim On Thu, Mar 10, 2016 at 12:28 AM, carol white via R-help wrote: > 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 > 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 > 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]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] group by rows
On Wed, Mar 9, 2016 at 8:28 AM, carol white wrote: > What should be FUN in aggregate as no function like mean, sum etc will be > applied I have no idea, since you haven't told us what you want the results to look like. > Carol > > > On Wednesday, March 9, 2016 1:59 PM, Sarah Goslee > 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 > 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 > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] group by rows
Hi Without posting some data by dput, you hardly get any sensible answer. You can use any function which gives you appropriate result, even your own. Or even silly one like aggregate(iris[,1:3], list(iris$Species), paste, collapse="") Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of carol > white via R-help > Sent: Wednesday, March 09, 2016 2:28 PM > To: Sarah Goslee > Cc: R-help Help > Subject: Re: [R] group by rows > > 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 > 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 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]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] group by rows
> 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}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] group by rows
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 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 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]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] group by rows
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 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]] > > ___ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] group by rows
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]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.