windsector_convert: Convert input "windsector" to list if needed

View source: R/foehnix_functions.R

windsector_convertR Documentation

Convert input "windsector" to list if needed

Description

Converts user inputs to list. Wind sector information is used to highlight specific wind sectors on the plots (e.g., tsplot, windrose).

Usage

windsector_convert(x)

Arguments

x

NULL, list, matrix, or data.frame. see 'Details' for more information.

Details

Some foehnix functions allow to specify custom wind sectors. This function is a convenience function which takes inputs in different formats (e.g., as matrix, data.frame, ...) and converts the information in the format the foehnix functions expect wind sector definitions.

Value

Returns a list object with the windsector information as used by the different functions and methods of the foehnix package.

Returns NULL (if input was NULL) or a named or unnamed with one or multiple entries. Each entry is a numeric vector of length two and specifies a wind sector.

Author(s)

Reto Stauffer

Examples

# No wind sector (NULL) simply returns NULL
foehnix:::windsector_convert(NULL)

# Input can also be:
# - unnamed list
# - a matrix
# - a data.frame without row names
foehnix:::windsector_convert(matrix(c(10, 30, 90, 140), byrow = TRUE, ncol = 2))
foehnix:::windsector_convert(list(c(10, 30), c(90, 140)))
foehnix:::windsector_convert(data.frame(from = c(30, 90), to = c(30, 140)))

# Or named objects can be used
# - named list
# - matrix with rownames
# - data.frame with rownames
# If names are set these names will be used to label the
# highlighted wind sectors.
foehnix:::windsector_convert(matrix(c(10, 30, 90, 140), byrow = TRUE, ncol = 2,
                         dimnames = list(c("A", "B"), c("from", "to"))))
foehnix:::windsector_convert(list(A = c(10, 30), B = c(90, 140)))
foehnix:::windsector_convert(structure(data.frame(from = c(30, 90), to = c(30, 140)),
                                       row.names = c("foo", "bar")))


retostauffer/Rfoehnix documentation built on June 5, 2023, 11:39 p.m.