On Mon, 23 Apr 2012, Vikram Bahure wrote:

Dear R users,

I want to subset a daily zoo series according to its month, find % of "NA"
in each month.

I am finding it difficult to subset the daily dataset into monthly for the
given operation.I am planning to do this for a huge dataset.

Use aggregate(z, as.yearmon, ...) for aggregation to a monthly series. A simple artificial example is:

## data with NAs
set.seed(1)
x <- rnorm(50)
x[sample(1:50, 10)] <- NA

## as zoo
z <- zoo(x, as.Date("2012-01-01") + 0:49)

## proportion of NAs
aggregate(z, as.yearmon, function(x) mean(is.na(x)))

hth,
Z

Thanks in advance.

Regards
Vikram

        [[alternative HTML version deleted]]

______________________________________________
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-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