s-news
[Top] [All Lists]

Summary: tapply()

To: "S-PLUS Newsgroup (E-mail)" <s-news@lists.biostat.wustl.edu>
Subject: Summary: tapply()
From: Winnie Lambert <lambert.winifred@ensco.com>
Date: Thu, 13 Dec 2001 17:00:00 -0500
All,
 
Sincere thanks to all who suggested to make $Hour a factor:
 
Russel Zaretzki
Samuel Buttrey
Vadim Kutsyy
Nick Ellis
Bill Dunlap
Glenn Treacy
Bob Byers
Terry Therneau
 
The actual command that worked was
 
> tapply ( get(infile)$Spd[good.s], as.factor( get(infile)$Hour )[good.s], mean )
 
If you use this, make sure that the [good.s] is outside the function call to as.factor()
The same worked for the length with an extra command to change the NA to 0
 
> x <-  tapply( get(infile)$Spd[good.s], as.factor( get(infile)$Hour )[good.s], length )
> x[is.na(x)] <- 0
 
Thanks again.  The responses were really fast and useful.
 
Win Lambert
 
<Prev in Thread] Current Thread [Next in Thread>
  • Summary: tapply(), Winnie Lambert <=