Learn R Programming

eva3dm (version 1.11)

select: Selection from data.frames with time-series

Description

Utility function to select periods from a data.frame. This function is inspired by openair::selectByDate.

Usage

select(
  data,
  year,
  month,
  day,
  hour,
  minutes,
  seconds,
  start,
  end,
  range,
  time = "date"
)

Value

data.frame

Arguments

data

data.frame with model or observation data

year

numeric vector for selection

month

numeric vector (1-12) for selection, can be abbreviated to 3 or more letters

day

numeric vector (1-31) for selection, weekdays can be abbreviated to 3 or more letters, or weekday/weekend

hour

numeric vector (0-23) for selection

minutes

numeric vector (0-60) for selection

seconds

numeric vector (0-60) for selection

start

POSIXct or character (YYYY-MM-DD) with the initial date of selection

end

POSIXct or character (YYYY-MM-DD) with the initial date of selection

range

pair of start/end or a data.frame with time (default is "date")

time

name of the column for time (default is "date")

See Also

See %IN% for selection based on position and model domains.

Examples

Run this code
model <- readRDS(paste0(system.file("extdata",package="eva3dm"),
                        "/model.Rds"))
summary(model)
summary(select(data = model, start = '2012-01-09'))
summary(select(data = model, start = '2012-01-05', end  = '2012-01-09'))
summary(select(data = model, day  = 6))
summary(select(data = model, hour = 12))
summary(select(data = model, day = 6, hour = 12))
summary(select(data = model, day  = 'weekday'))
summary(select(data = model, day  = 'weekend'))
summary(select(data = model, day  = 'tue'))
summary(select(data = model, day  = 'jan'))

Run the code above in your browser using DataLab