Skip to contents

Construct and validate a pred_data_t objects, which are used to store predictor data. Different data types (float, int, bool) have different subclasses (pred_data_t_float, ...)

Usage

as_pred_data_t(x)

# S3 method for class 'pred_data_t'
print(x, nrow = 10, ...)

pred_data_available_v(self)

trans_pred_data_v(self, id_trans, id_pred, ordered = FALSE)

pred_data_wide_v(self, id_trans, id_period_anterior)

set_pred_coltypes(result, pred_meta_t)

add_predictor(
  self,
  pred_data_raw,
  name,
  fill_value,
  pretty_name = name,
  description = NA_character_,
  orig_format = NA_character_,
  sources = list(),
  unit = NA_character_
)

Arguments

x

Coercible to data.table

nrow

see data.table::print.data.table

...

passed to data.table::print.data.table

self,

evoland_db instance to query

id_trans

Integer transition ID, see trans_meta_t

id_pred

Optional integer vector of predictor IDs to include; if missing, use all predictor IDs from pred_meta_t

ordered
  • if TRUE, order output by id_period then id_coord (otherwise no guaranteed order; need ordering for reproducible subsampling)

id_period_anterior

Scalar integerish of anterior period ID, i.e. we get the predictors that explain the processes over the next N years

result

data.table with predictor columns named id_pred_{n}

pred_meta_t

see pred_meta_t

pred_data_raw

data.table with columns id_coord, id_period, and value (predictor value); the data type of the value is stored in pred_meta_t

name

Character scalar, unique name of predictor. If already present in pred_meta_t, this will simply update the information.

fill_value

Value to use for coordinates registered in coords_t but not in the provided pred_data_raw. e.g. where no known population is registered, assume pop. 0. For a factor variable, this could be a base case, e.g. for different nature reserve types, this could be the "not in a reserve" type.

pretty_name

opt. Character scalar, friendly name for plots/output

description

opt. Character scalar. Long description / operationalisation

orig_format

opt. Character scalar. Original format description

sources

opt. list of lists: each list containing one url and a md5sum field, see create_pred_meta_t() and download_and_verify()

unit

opt. Character scalar. SI unit for physical properties, or more complex descriptors like "bed nights/year" as a proxy for touristic activity

self

an evoland_db instance

Value

A data.table of class "pred_data_t" with columns:

  • id_run: Foreign key to runs_t

  • id_pred: Foreign key to pred_meta_t

  • id_coord: Foreign key to coords_t

  • id_period: Foreign key to periods_t

  • value: Predictor value (coerced to double, recoverable through pred_meta_t)

data.table with columns id_coord, id_period, did_transition (bool), and one column per predictor (id_pred_{n})

Methods (by generic)

  • print(pred_data_t): Print a pred_data_t object, passing params to data.table print

Functions

  • pred_data_available_v(): Check if predictor data is complete, i.e. each entry in pred_meta_t is either present in period 0 or for all other periods for a given run.

  • trans_pred_data_v(): Get transitions along with their predictor data in a wide data.table

  • pred_data_wide_v(): Get predictor data in a wide data.table for transition potential prediction (cols id_coord, id_pred_{n})

  • set_pred_coltypes(): In-place casting of predictor columns to their correct data types based on pred_meta_t; also fills NA values with fill_value from pred_meta_t if specified

  • add_predictor(): Add a predictor to the database, given a data.table with columns id_coord, id_period, and value (predictor value). Uses the current id_run.