Learn R Programming

hydroTSM (version 0.3-4)

vector2zoo: Vector -> Zoo

Description

Transform a numeric vector and its corresponding dates into a zoo object.

Usage

vector2zoo(x, dates, date.fmt = "%Y-%m-%d")

Arguments

x
numeric vector
dates
character, factor or Date object with the dates corresponding to each element of x. Valid object class for dates are: character, factor, Date
date.fmt
character indicating the format in which the dates are stored in dates, e.g. %Y-%m-%d. See format in as.Date. ONLY required when class(dates)=="factor" o

Value

  • a zoo object, with the same number of elements as x.

See Also

izoo2rzoo, dip, mip, yip

Examples

Run this code
# Generating a numeric variable (e.g., read from the outputs of an hydrological model)
x <- 1:31

# Generating the dates corresponding to the previous outputs
dates <- dip("1961-01-01", "1961-01-31")

## Transforming from 'numeric' to 'zoo' class
x <- vector2zoo(x, dates)

Run the code above in your browser using DataLab