[R] dynamic aggregation of many variables

Christian Schulz ozric at web.de
Wed Nov 15 12:43:01 CET 2006


Hi,

i have many variables for in example 4weeks and want to do
aggregations, like mean standard , deviation etc..

With mean it works but how i can  calculate the standard deviation for 
the 4weeks and for every  ID.

many thanks & regards, christian

week1 <- grep("(_PRO_001)",names(dmx3),perl=T)
week1table <- subset(dmx3,select=c(ID,week1))

week2 <- grep("(_PRO_002)",names(dmx3),perl=T)
week2table <- subset(dmx3,select=c(ID,week2))

week3 <- grep("(_PRO_003)",names(dmx3),perl=T)
week3table <- subset(dmx3,select=c(ID,week3))

week4 <- grep("(_PRO_004)",names(dmx3),perl=T)
week4table <- subset(dmx3,select=c(ID,week4))
mws <- 
(week1table[,2:117]+week2table[,2:117]+week3table[,2:117]+week4table[,2:117])/4



More information about the R-help mailing list