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.

as_task_regr_st(x, ...)

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

# S3 method for 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 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 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

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"))
#> <TaskRegrST:cookfarm_sample> (500 x 23) #> * Target: PHIHOX #> * Properties: - #> * Features (22): #> - dbl (18): BLD, LHDICM, Port1C, Port1EC, Port1VW, Port2C, Port2EC, #> Port2VW, Port3C, Port3EC, Port3VW, Port4C, Port4EC, Port4VW, #> Port5C, Port5EC, Port5VW, UHDICM #> - fct (3): HZDUSD, SOURCEID, TAXSUSDA #> - chr (1): Date #> * Coordinates: #> x y #> 1: 493560.7 5180929 #> 2: 493927.2 5180836 #> 3: 494076.9 5180950 #> 4: 493544.3 5180832 #> 5: 493671.9 5180833 #> --- #> 496: 493628.3 5180612 #> 497: 493767.4 5181034 #> 498: 493817.8 5181085 #> 499: 493832.3 5180624 #> 500: 493604.1 5180859
# sf cookfarm_sf = sf::st_as_sf(cookfarm_sample, coords = c("x", "y"), crs = 26911) as_task_regr_st(cookfarm_sf, target = "PHIHOX")
#> <TaskRegrST:cookfarm_sf> (500 x 23) #> * Target: PHIHOX #> * Properties: - #> * Features (22): #> - dbl (18): BLD, LHDICM, Port1C, Port1EC, Port1VW, Port2C, Port2EC, #> Port2VW, Port3C, Port3EC, Port3VW, Port4C, Port4EC, Port4VW, #> Port5C, Port5EC, Port5VW, UHDICM #> - fct (3): HZDUSD, SOURCEID, TAXSUSDA #> - chr (1): Date #> * Coordinates: #> X Y #> 1: 493560.7 5180929 #> 2: 493927.2 5180836 #> 3: 494076.9 5180950 #> 4: 493544.3 5180832 #> 5: 493671.9 5180833 #> --- #> 496: 493628.3 5180612 #> 497: 493767.4 5181034 #> 498: 493817.8 5181085 #> 499: 493832.3 5180624 #> 500: 493604.1 5180859
# TaskRegrST task = tsk("cookfarm") as_task_regr_st(task)
#> <TaskRegrST:cookfarm> (500 x 23) #> * Target: PHIHOX #> * Properties: - #> * Features (22): #> - dbl (18): BLD, LHDICM, Port1C, Port1EC, Port1VW, Port2C, Port2EC, #> Port2VW, Port3C, Port3EC, Port3VW, Port4C, Port4EC, Port4VW, #> Port5C, Port5EC, Port5VW, UHDICM #> - fct (3): HZDUSD, SOURCEID, TAXSUSDA #> - chr (1): Date #> * Coordinates: #> x y #> 1: 493560.7 5180929 #> 2: 493927.2 5180836 #> 3: 494076.9 5180950 #> 4: 493544.3 5180832 #> 5: 493671.9 5180833 #> --- #> 496: 493628.3 5180612 #> 497: 493767.4 5181034 #> 498: 493817.8 5181085 #> 499: 493832.3 5180624 #> 500: 493604.1 5180859