as_task_regr_st: Convert to a Spatiotemporal Regression Task

Description Usage Arguments Value Examples

View source: R/as_task_regr_st.R

Description

Convert an object to a TaskRegrST. This is a S3 generic for the following objects:

  1. TaskRegrST: ensure the identity

  2. data.frame() and DataBackend: provides an alternative to the constructor of TaskRegrST.

  3. sf::sf.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
as_task_regr_st(x, ...)

## S3 method for class 'TaskRegrST'
as_task_regr_st(x, clone = FALSE, ...)

## S3 method for class 'data.frame'
as_task_regr_st(
  x,
  target = NULL,
  id = deparse(substitute(x)),
  crs = NA,
  coords_as_features = FALSE,
  coordinate_names = NA,
  ...
)

## S3 method for class 'DataBackend'
as_task_regr_st(
  x,
  target = NULL,
  id = deparse(substitute(x)),
  crs = NA,
  coords_as_features = FALSE,
  coordinate_names = c("x", "y"),
  ...
)

## S3 method for class 'sf'
as_task_regr_st(
  x,
  target = NULL,
  id = deparse(substitute(x)),
  coords_as_features = FALSE,
  ...
)

Arguments

x

(any)
Object to convert.

...

(any)
Additional arguments.

clone

(logical(1))
If TRUE, ensures that the returned object is not the same as the input x.

target

(character(1))
Name of the target column.

id

(character(1))
Id for the new task. Defaults to the (deparsed and substituted) name of x.

crs

[character(1)]
Coordinate reference system. Either a PROJ string or an EPSG code.

coords_as_features

[logical(1)]
Whether the coordinates should also be used as features.

coordinate_names

(character())
The variables names of the coordinates in the data.

Value

TaskRegrST.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library("mlr3")
data("cookfarm_sample", package = "mlr3spatiotempcv")

# data.frame
as_task_regr_st(cookfarm_sample, target = "PHIHOX",
  coords_as_features = FALSE,
  crs = 26911,
  coordinate_names = c("x", "y"))

# sf
cookfarm_sf = sf::st_as_sf(cookfarm_sample, coords = c("x", "y"), crs = 26911)
as_task_regr_st(cookfarm_sf, target = "PHIHOX")

# TaskRegrST
task = tsk("cookfarm")
as_task_regr_st(task)

mlr-org/mlr3spatiotempcv documentation built on June 4, 2021, 11:16 p.m.