[R] how to combine data of several csv-files
Antje
niederlein-rstat at yahoo.de
Mon Jul 30 14:09:21 CEST 2007
okay, I played a bit around and now I have some kind of testcase for you:
v1 <- NA
v2 <- rnorm(6)
v3 <- rnorm(6)
v4 <- rnorm(6)
v5 <- rnorm(6)
v6 <- rnorm(6)
v7 <- rnorm(6)
v8 <- rnorm(6)
v8 <- NA
list <- list(v1,v2,v3,v4,v5,v6,v7,v8)
categ <- c(NA,"cat1","cat1","cat1","cat2","cat2","cat2",NA)
> list
[[1]]
[1] NA
[[2]]
[1] -0.6442149 -0.2047012 -1.1986041 -0.2097442 -0.7343465 -1.3888750
[[3]]
[1] 0.02354036 -1.36186952 -0.42197792 1.50445971 -1.76763996 0.53722404
[[4]]
[1] -1.40362589 0.13045724 -0.84651458 1.57005071 0.06961015 0.25269771
[[5]]
[1] -1.1829260 2.1411553 -0.1327081 -0.1053442 -0.8179396 -1.2342698
[[6]]
[1] 1.17099178 0.49248118 -0.18690065 1.50050976 -0.65552410 -0.01243247
[[7]]
[1] -0.046778203 -0.233788840 0.443908897 -1.649740180 0.003991354 -0.228020092
[[8]]
[1] NA
now, I need the means (and sd) of element 1 of list[2],list[3],list[4] (because they belong to "cat1") and
= mean(-0.6442149, 0.02354036, -1.40362589)
the same for element 2 up to element 6 (--> I would the get a vector containing the means for "cat1")
the same for the vectors belonging to "cat2".
does anybody now understand what I mean?
Antje
More information about the R-help
mailing list