spm_as_dataset: Create a 'sspm_dataset' dataset structure

spm_as_datasetR Documentation

Create a sspm_dataset dataset structure

Description

This casts a data.frame or sf object into an object of class sspm_dataset. This object is the format the package uses to manage and manipulate the modeling data.

Usage

spm_as_dataset(data, name, time, uniqueID, coords = NULL, ...)

## S4 method for signature 'data.frame,ANY,ANY,ANY,missingOrNULL'
spm_as_dataset(
  data,
  name,
  time,
  uniqueID,
  coords,
  crs = NULL,
  boundaries = NULL,
  biomass = NULL,
  density = NULL,
  biomass_units = NULL,
  density_units = NULL
)

## S4 method for signature 'data.frame,ANY,ANY,ANY,list'
spm_as_dataset(
  data,
  name,
  time,
  uniqueID,
  coords,
  crs = NULL,
  boundaries = NULL,
  biomass = NULL,
  density = NULL,
  biomass_units = "kg",
  density_units = "kg/km^2"
)

## S4 method for signature 'data.frame,ANY,ANY,ANY,character'
spm_as_dataset(
  data,
  name,
  time,
  uniqueID,
  coords,
  crs = NULL,
  boundaries = NULL,
  biomass = NULL,
  density = NULL,
  biomass_units = "kg",
  density_units = "kg/km^2"
)

## S4 method for signature 'sf,ANY,ANY,ANY,ANY'
spm_as_dataset(
  data,
  name,
  time,
  uniqueID,
  coords,
  crs = NULL,
  boundaries = NULL,
  biomass = NULL,
  density = NULL,
  biomass_units = "kg",
  density_units = "kg/km^2"
)

Arguments

data

[data.frame OR sf] The dataset.

name

[character] The name of the dataset, default to "Biomass".

time

[character] The column of data for the temporal dimensions (i.e. year).

uniqueID

[character] The column of data that is unique for all rows of the data matrix.

coords

[character] The column of data for longitude and latitude of the observations.

...

Arguments passed onto methods.

crs

Coordinate reference system, passed onto st_as_sf.

boundaries

[sspm_boundary] An object of class sspm_discrete_boundary.

biomass

[character] Columns to be encoded as biomasses (required).

density

[character] Columns to be encoded as densities (optionnal).

biomass_units

[character] Units for biomass columns, default to "kg".

density_units

[character] Units for density columns, default to "kg/km^2".

Value

An object of class sspm_dataset.

Examples

data(borealis_simulated, package = "sspm")
biomass_dataset <- spm_as_dataset(data.frame(borealis_simulated), name = "borealis",
                                  density = "weight_per_km2",
                                  time = "year_f",
                                  coords = c('lon_dec','lat_dec'),
                                  uniqueID = "uniqueID")
biomass_dataset


pedersen-fisheries-lab/spaspm documentation built on Feb. 16, 2025, 7:39 p.m.