Description Usage Arguments Details Value Examples
View source: R/dataframe2zoo.R
extractzoo
and tycho2zoo
extracts regular time series of class zooreg
from a
dataframe or tibble.
1 2 3 4 | dataframe2zoo(dataset, index, data, FUN = "sum")
tycho2zoo(dataset, index = "PeriodEndDate", data = "CountValue",
FUN = "sum")
|
dataset |
Data Frame or Tibble with at least one variabel of class |
index |
Character. Name of variable to use as index. Variable must be of class |
data |
Character. Name of variable to use as data. |
FUN |
Name of function to use for aggregation. May be quoted or not. Default = |
extractzoo
aggregates the data
by summing for each unique value of index
,
calculates the underlying time interval of the data, pads missing data with NA
's, and
returns a regular time series (numeric vector) of class zooreg
. See
zooreg
for details.
tycho2zoo
is a convenience wrapper for extractzoo
with default values
index = "PeriodEndDate"
and data = "CountValue"
.
A regular time series of class zooreg
.
1 2 3 4 5 6 7 8 9 10 11 | mydata <- data.frame(date = as.Date(c("2000/1/1",
"2000/1/1",
"2000/1/8",
"2000/1/22",
"2000/1/29",
"2000/1/29")),
city = c("NY","BOS","NY","NY","BOS","NY"),
temp = c(2.0, 0.5, 5.5, 3.8, 7.1, 9.0))
mydata
meantemp <- dataframe2zoo(mydata, index="date", data="temp", FUN=mean)
meantemp
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.