cmv | R Documentation |
Generic function for counting the percentage/amount of missing values in a zoo object, using a user-defined temporal scale.
cmv(x, ...)
## Default S3 method:
cmv(x, tscale=c("hourly", "daily", "weekly", "monthly",
"quarterly", "seasonal", "annual"),
out.type=c("percentage", "amount"), dec=3,
start="00:00:00", start.fmt= "%H:%M:%S", tz, ...)
## S3 method for class 'zoo'
cmv(x, tscale=c("hourly", "daily", "weekly", "monthly",
"quarterly", "seasonal", "annual"),
out.type=c("percentage", "amount"), dec=3,
start="00:00:00", start.fmt= "%H:%M:%S", tz, ...)
## S3 method for class 'data.frame'
cmv(x, tscale=c("hourly", "daily", "weekly", "monthly",
"quarterly", "seasonal", "annual"),
out.type=c("percentage", "amount"), dec=3,
start="00:00:00", start.fmt= "%H:%M:%S", tz,
dates=1, date.fmt="%Y-%m-%d", ...)
## S3 method for class 'matrix'
cmv(x, tscale=c("hourly", "daily", "weekly", "monthly",
"quarterly", "seasonal", "annual"),
out.type=c("percentage", "amount"), dec=3,
start="00:00:00", start.fmt= "%H:%M:%S", tz,
dates=1, date.fmt="%Y-%m-%d", ...)
x |
zoo, data.frame or matrix object, with the time series to be analised. |
tscale |
character with the temporal scale to be used for analysing the mssing data. Valid values are: |
dec |
integer indicating the amount of decimal places included in the output. |
start |
character, indicating the starting time used for aggregating sub-daily time series into daily ones. It MUST be provided in the format specified by It is useful when the daily values start at a time different from |
start.fmt |
character indicating the format in which the time is provided in |
tz |
character, with the specification of the time zone used in both |
dates |
numeric, factor, POSIXct or POSIXt object indicating how to obtain the dates and times for each column of |
date.fmt |
character indicating the format in which the dates are stored in |
out.type |
character indicating how should be returned the missing values for each temporal scale. Valid values are: |
... |
further arguments passed to or from other methods. |
The amount of missing values in each temporal scale is computed just by counting the amount of NAs in each hour / day / week / month / quarter / season / year, while the percentage of missing values in each temporal scale is computed by dividing the previous number by the total number of data elements in each hour / day / week / month / quarter / season / year.
This function was developed to allow the selective removal of values when agregting from a high temporal resolution into a lower temporal resolution (e.g., from hourly to daily or from daily to monthly), using any of the temporal aggregation functions available int his package (e.g., hourly2daily
, daily2monthly
)
a zoo object with the percentage/amount of missing values for each temporal scale selected by the user.
Mauricio Zambrano-Bigiarini, mzb.devel@gmail
dwi
, subhourly2hourly
, subdaily2daily
, daily2monthly
, daily2annual
, monthlyfunction
, izoo2rzoo
######################
## Ex1: Loading the DAILY precipitation data at SanMartino (25567 daily values)
data(SanMartinoPPts)
x <- SanMartinoPPts
## Transforming into NA the 10% of values in 'x'
n <- length(x)
n.nas <- round(0.1*n, 0)
na.index <- sample(1:n, n.nas)
x[na.index] <- NA
# Getting the amount of NAs in 'x' for each week (starting on Monday)
cmv(x, tscale="weekly")
# Getting the amount of NAs in 'x' for each month
cmv(x, tscale="monthly")
# Getting the amount of NAs in 'x' for each quarter
cmv(x, tscale="quarterly")
# Getting the amount of NAs in 'x' for each weather season
cmv(x, tscale="seasonal")
# Getting the amount of NAs in 'x' for each year
cmv(x, tscale="annual")
######################
## Ex2: Loading the time series of HOURLY streamflows for the station
## Karamea at Gorge (52579 hourly values)
data(KarameaAtGorgeQts)
x <- KarameaAtGorgeQts
## Transforming into NA the 30% of values in 'x'
n <- length(x)
n.nas <- round(0.1*n, 0)
na.index <- sample(1:n, n.nas)
x[na.index] <- NA
# Getting the amount of NAs in 'x' for each day
cmv(x, tscale="daily")
# Getting the amount of NAs in 'x' for each weather season
cmv(x, tscale="seasonal")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.