Dear list,

I'm still trying to calculate the sd for V2 for
each group in V1 if V3 is '0':

> x
    V1   V2 V3
1 A01 2.40  0
2 A01 3.40  1
3 A01 2.80  0
4 A02 3.20  0
5 A02 4.20  0
6 A03 2.98  1
7 A03 2.31  0
8 A04 4.20  0

# Work
x$vmean <- ave(x$V2, x$V1, x$V3 == 0, FUN = mean)

# Work
x$vsd2 <- ave(x$V2, x$V1, FUN = sd)

# Doesn't work
x$vsd <- ave(x$V2, x$V1, x$V3 == 0, FUN = sd)

Thank you for any help!

Patrick

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to