ecvetano at uwaterloo.ca
2010-May-31 18:06 UTC
[R] How to skip negative values when calculating average
I have a data frame 10 by 12 with positive and negative numbers. I want to select only the positive numbers and find the average. This calculates the average of everything: av5 <- subset(ER9r, Day == 253, select = c (Depth1j:Depth0.75j) av5 <- mean(av5) I need something along the lines of "select" av5>0 Thanks in advance! Emilija
David Winsemius
2010-May-31 19:03 UTC
[R] How to skip negative values when calculating average
On May 31, 2010, at 2:06 PM, ecvetano at uwaterloo.ca wrote:> I have a data frame 10 by 12 with positive and negative numbers. I > want to select only the positive numbers and find the average. > > This calculates the average of everything: > av5 <- subset(ER9r, Day == 253, select = c (Depth1j:Depth0.75j)That looks to be missing a closing paren. If so, then after fixing you first line try: mean( av5[av5>0] )> av5 <- mean(av5) > I need something along the lines of "select" av5>0 > > Thanks in advance! > > Emilija > > ______________________________________________David Winsemius, MD West Hartford, CT