Pivot data obtained with the function gwr. Groups all the data points for each entity/row into a single list of elements.

pivot_data(
  .data,
  timestep = "^T[0-9]*",
  cols = colnames(.data) %>% stringr::str_detect(timestep, negate = TRUE) %>%
    which(),
  scale = 1,
  add = 0,
  varname = "value"
)

Arguments

.data

Data frame (tibble object) obtained with gwr.

timestep

String with the pattern used to name each data point at each time-step. Default: "^T[0-9]*".

cols

Metadata columns (latitude, longitude, etc.), to be excluded from the data pivoting. Default: excluded columns matching the timestep pattern, for the default pattern, ignores columns with the prefix T and digits as suffix (e.g., T1, T2, ..., Tt, etc.).

scale

Numeric value to scale the data. Default: 1, no scaling.

add

Numeric value to be added/subtracted from the data points. Default: 0, don't add anything.

varname

Output variable name. Default: "value".

Value

Data frame (tibble object) with a new column named according to the string passed with value, this new column contains a list of the data points at each time step for each observation/row.

Examples

if (FALSE) {
`%>%` <- magrittr::`%>%`
data <- tibble::tibble(entity_name = "University of Reading",
                       latitude = 51.44140,
                       longitude = -0.9418,
                       elevation = 61)
smpds::gwr(.ref = "/path/to/reference-tmp.nc",
           .tar = data,
           varid = "tmp") %>%
  smpds::pivot_data(varname = "tmp")
}