Displaying 2 results from an estimated 2 matches for "vsd2".
Did you mean:
vs02
2007 Nov 21
1
ave and sd
...,
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
2007 Nov 23
0
R users in Cyprus
...39;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)
Problem comes from
lapply(split(x$V2, interaction(x$V1, x$V3)), sd)
specifically from
> split(x$V2, interaction(x$V1, x$V3))
<snip>
$A02.1
numeric(0)
$A03.1
[1] 2.98...