pacea_long: pacea spatiotemporal data convert to long/wide format

View source: R/pacea-wrangle.R

pacea_longR Documentation

pacea spatiotemporal data convert to long/wide format

Description

Simplified function for users, taking the ‘tidyr::pivot_longer' and 'tidyr::pivot_wider' functions to transform pacea.st data into long or wide format for simpler data manipulation, summarising, and plotting. Writted to only work with ’pacea.st' (spatiotemporal) data.

Usage

pacea_long(data, names_to = "date", values_to = "value")

pacea_wide(data, names_from = c("year", "month"), values_from = "value")

Arguments

data

pacea.st data object in long format to pivot.

names_to

A character value for the column name representing the date. Defaults to separate 'year' and 'month' for BCCM data.

values_to

A character value for the column name representing variable data (e.g. temperature)

names_from

A character vector representing the date from which to name columns from. If vector is greater than 1, column values will be pasted together, separated by '_'. Defaults to paste BCCM data in 'year_month' format.

values_from

A character value representing the column names from which to get variable data values.

Value

pacea spatiotemporal data in long/wide format

Examples

## Not run: 
pdata <- bccm_surface_temperature()[,1:2]
pdata_long <- pacea_long(pdata)
head(pdata_long)

## End(Not run)
## Not run: 
pdata <- bccm_surface_temperature()[,1:2]
pdata_long <- pacea_long(pdata)
pdata_wide <- pacea_wide(pdata)
head(pdata_wide)

## End(Not run)

pbs-assess/PACea documentation built on April 17, 2025, 11:36 p.m.