[R] How to skip negative values when calculating average

From: <ecvetano_at_uwaterloo.ca>
Date: Mon, 31 May 2010 14:06:40 -0400


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



R-help_at_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. Received on Mon 31 May 2010 - 18:42:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 31 May 2010 - 19:10:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive