[R] Mean(s) from values in different row?

2011-10-05 Thread SML
Hello:

Is there a way to get a mean from values stored in different rows? 

The data looks like this:
  YEAR-1, JAN, FEB, ..., DEC
  YEAR-2, JAN, FEB, ..., DEC
  YEAR-3, JAN, FEB, ..., DEC

What I want is the mean(s) for just the consecutive winter months:
  YEAR-1.DEC, YEAR-2.JAN, YEAR-2.FEB
  YEAR-2.DEC, YEAR-3.JAN, YEAR-3.FEB
  etc.

Thanks.

__
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.


[R] Rekeying value denoting NA

2011-11-07 Thread SML
I'm trying to rekey values which denote there is no values, i.e.,
'-999' in a dataset which contains both '-999' and NA entries.
When I try the following command I get the following error:

> data.frame[data.frame$MAR <= -9,"MAR"] <- NA

"missing values are not allowed in subscripted assignments of data
frames"

Example of data:
YEAR   JAN FEB MAR ... DEC
1931   5   -999NA  3
1932   2   1   -9992
.
.
.
2010   -999NA  2   1


I've tried to replace the NAs with -999 values first to remove the NA
values, but got the same error.

I'm quite new to R, and these little issues seem to be a stumbling
block. Many thanks for any help you might be able to offer.

__
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.