[R] Data
David Winsemius
dwinsemius at comcast.net
Fri Dec 11 23:03:24 CET 2009
On Dec 11, 2009, at 4:38 PM, Jose Narillos de Santos wrote:
> Hi all,
>
> Imagine I have a matrix and the first colum is a list that repeats
> the same
> names, I want to sum the second column on each unique name on first
> column.
>
> Imagine this:
>
> Pepe 2
> Pepe 3
> Pepe 4
> Jose 2
> Jose 5
> Manuel 4
> Manuel 2
?tapply # or one of its derivative fucntions like by or aggregate
>
> I want to make a new matrix that calculates and recognizes that
> there are 3
> different names ans sum second column. But a priori I don´t know the
> list of
> the different names:
>
> In my example
Something like:
tapply(valuecol, namecol, sum)
(Untested.)
>
> Pepe 9
> Jose 7
> Manuel 6
>
> I´m trying to use something like sapply or apply but I can find the
> key...
>
> Can anyone help or guide me ?
>
> Thanks in advance¡¡¡
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list