[R] Computting statistics on a matrix with 2 factor column

Chuck Cleland ccleland at optonline.net
Tue Jun 8 15:44:02 CEST 2004


?tapply
?aggregate

   You probably have a data frame, not a matrix.

Marc Mamin wrote:
> I suppose this is a basic question but couldn't find a solution.:
> 
> I have a large matrix with let say 3 columns:
> 
> V1	V2	V3
> a	x	2
> a	x	4
> a	y	8
> b	z	16
> 
> and I want to compute some statistics based on 
> the levels resulting form the combination of the two first columns
> 
> e.g.:
> 
> SUM->
> 
> V1	V2	V3
> a	x	6
> a	y	8
> b	z	16

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list