| isComplete | R Documentation |
Generic function for identifying whether a zoo object has a regular time frequency without missing values from the first one to the last one.
isComplete(x, ...)
## S3 method for class 'zoo'
isComplete(x, tz, out.type=c("single", "all"), verbose=TRUE, ...)
x |
zoo object with a time attribute that should have a regular time frequency (e.g., hourly, daily, monthly, annual). |
tz |
character, indicating the time zone in which the date of If If A list of valid time zones can be obtained by calling the base function This argument can be used when working with sub-daily zoo objects to force using time zones other than the local time zone for |
out.type |
Character indicating the type of result that is given by this function. Valid values are: |
verbose |
logical; if TRUE, informative messages are shown in the screen. When |
... |
further arguments passed to or from other methods. |
If \code{out.type="single"} |
(default value), it returns a logical value identifying whether |
If \code{out.type="all"} |
it returns a list with the following three elements: -) isComplete: logical value identifying whether -) NumberMissingDT: integer indicating the amount of missing layers from the first layer of -) missingDateTimes: Numeric, Date, or POSIXct vector showing the DateTime of the missing layers in |
Mauricio Zambrano-Bigiarini, mzb.devel@gmail.com
window
###########
# EXAMPLE 1: Hourly zoo object, with a POSIXct time attribute
###########
# Loading the HOURLY streamflow data for Karamea at Gorge
data(KarameaAtGorgeQts)
x.h <- KarameaAtGorgeQts
# Checking whether 'x' is complete or not
isComplete(x.h)
###########
## EXAMPLE 2: Daily object, with a Date time attribute
###########
# Loading the DAILY precipitation data at SanMartino
data(SanMartinoPPts)
x.d <- SanMartinoPPts
# Checking whether 'x' is complete or not
isComplete(x.d)
# Removing two values and testing it again
x.d <-x.d[-c(3,5)]
isComplete(x.d)
###########
# EXAMPLE 3: Weekly zoo object, with a Date time attribute
###########
# Creating a dummy weekly object with a Date time attribute
x.w <- x.d[1:12]
time(x.w) <- seq(from=as.Date("2001-01-01"), to=as.Date("2001-03-19"),
by="1 week")
# Checking whether 'x.w' is complete or not
isComplete(x.w)
# Removing two values and testing it again
x.w2 <- x.w[-c(3,5)]
isComplete(x.w2)
###########
# EXAMPLE 4: Monthly zoo object, with a yearmon time attribute
###########
# Transforming the daily object into a monthly one
x.m1 <- daily2monthly(x.d, FUN=sum)
# Checking whether 'x.m1' is complete or not
isComplete(x.m1)
# Removing two values and testing it again
x.m12 <- x.m1[-c(3,5)]
isComplete(x.m12)
###########
# EXAMPLE 5: Monthly zoo object, with a Date time attribute
###########
# Creating a monthly object with a Date time attribute
x.m2 <- x.m1
time(x.m2) <- as.Date( paste0( format(zoo::as.yearmon( time(x.m1) ), "%Y-%m"), "-01") )
# Checking whether 'x.m2' is complete or not
isComplete(x.m2)
# Removing two values and testing it again
x.m22 <- x.m2[-c(3,5)]
isComplete(x.m22)
###########
# EXAMPLE 6: Annual zoo object, with a Date time attribute
###########
# Creating a dummy annual object with Date time attribute
x.a1 <- x.m1[1:12]
time(x.a1) <- hydroTSM::yip("2001-01-01", "2012-01-01")
# Checking whether 'x.a1' is complete or not
isComplete(x.a1)
# Removing two values and testing it again
x.a12 <- x.a1[-c(3,5)]
isComplete(x.a12)
###########
# EXAMPLE 7: 3-hourly zoo object, with a POSIXct time attribute
###########
# Creating a dummy 3-hourly object with a POSIXct time attribute
x.3h <- x.m1[1:12]
time(x.3h) <- seq(from=as.POSIXct("2001-01-01 00:00:00", tz="UTC"),
to=as.POSIXct("2001-01-02 09:00:00", tz="UTC"),
by="3 hours")
# Checking whether 'x.3h' is complete or not
isComplete(x.3h)
# Removing two values and testing it again
x.3h2 <- x.3h[-c(3,5)]
isComplete(x.3h2)
############
# EXAMPLE 8: 8-day zoo object, with a Date time attribute
############
# Creating a dummy 8-day object with a Date time attribute
x.8d <- x.m1[1:12]
time(x.8d) <- seq(from=as.Date("2001-01-01"), to=as.Date("2001-03-31"), by="8 days")
# Checking whether 'x.8d' is complete or not
isComplete(x.8d)
# Removing two values and testing it again
x.8d2 <- x.8d[-c(3,5)]
isComplete(x.8d2)
############
# EXAMPLE 9: 3-monthly zoo object, with a Date time attribute
############
# Creating a dummy 3-monthly object with a Date time attribute
x.3m <- x.m1[1:12]
time(x.3m) <- seq(from=as.Date("2001-01-01"), to=as.Date("2003-12-01"), by="3 months")
# Checking whether 'x.3m' is complete or not
isComplete(x.3m)
# Removing two values and testing it again
x.3m2 <- x.3m[-c(3,5)]
isComplete(x.3m2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.