wider: Pivot data from long to wide format

widerR Documentation

Pivot data from long to wide format

Description

Pivot data from long to wide format

Usage

wider(
  qnat,
  names_from = "code_stn",
  names_prefix = "stn_",
  values_from = "qnat"
)

Arguments

qnat

a tibble with tidy data. Usually the output from import_qnat.

names_from

<tidy-select> A pair of arguments describing which column (or columns) to get the name of the output column (names_from), and which column (or columns) to get the cell values from (values_from).

If values_from contains multiple values, the value will be added to the front of the output column.

names_prefix

String added to the start of every variable name. This is particularly useful if names_from is a numeric vector and you want to create syntactic variable names.

values_from

<tidy-select> A pair of arguments describing which column (or columns) to get the name of the output column (names_from), and which column (or columns) to get the cell values from (values_from).

If values_from contains multiple values, the value will be added to the front of the output column.

Details

This almost a wrapper function of tidyr::pivot_wider().

Value

a widen tibble version from input data (qnat). Each column will correspond to a time series of a station. Default for variable names will be a string like qnat_{names_from} . Most of the time the value of names_from is code_stn or id.

Examples

if(FALSE){
 qnat <- import_qnat(NA_character_, complete = TRUE, add_stn_info = TRUE)
 str(qnat)
 qnat_wide <- wider(qnat)
 str(qnat_wide)
}

lhmet/HEobs documentation built on July 11, 2022, 8:03 a.m.