Skip to content
Prev 169016 / 398506 Next

Odp: Collapsing panel data

Hi

r-help-bounces at r-project.org napsal dne 03.02.2009 09:43:04:
have
collapse
That is what are NA values for. There are quite useful functions for 
handling them.

y <- c("A", "", "", "B", "", "C")
x <- c(0.5, 0.2, 0.3, 0.1, 0.9, 0.4)
y[y==""]<-NA

from package zoo
y.na<-na.locf(y)

tapply(x,y.na, sum)
  A   B   C 
1.0 1.0 0.4 

or aggregate(...)

Regards
Petr
entries
have
http://www.R-project.org/posting-guide.html
Message-ID: <OF822A2228.D28BD9E4-ONC1257552.00321850-C1257552.00325159@precheza.cz>
In-Reply-To: <OF3AB12121.2FD2FC55-ONC1257552.002EBC03-C1257552.002FE373@e-control.at>