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.

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

# S4 method for 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 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 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 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(borealis_simulated, name = "borealis",
                                  density = "weight_per_km2",
                                  time = "year_f",
                                  coords = c('lon_dec','lat_dec'),
                                  uniqueID = "uniqueID")
#>   Casting data matrix into simple feature collection using columns: lon_dec, lat_dec
#> !  Warning: sspm is assuming WGS 84 CRS is to be used for casting
biomass_dataset
#> 
#> ‒‒ Dataset borealis ‒‒
#> →  [1800 rows, 9 columns]
#> →  Density : weight_per_km2
#> →  Time : year_f
#>