R/TaskSurv_rats.R

Defines functions load_rats

#' @title Rats Survival Task
#'
#' @name mlr_tasks_rats
#' @format [R6::R6Class] inheriting from [TaskSurv].
#'
#' @section Construction:
#' ```
#' mlr3::mlr_tasks$get("rats")
#' mlr3::tsk("rats")
#' ```
#'
#' @description
#' A survival task for the [survival::rats] data set.
#' Columns have been converted to integer, column "sex" has been converted to a factor.
#' @template seealso_task
NULL

load_rats = function() {
  data = load_dataset("rats", "survival")
  data = map_at(data, c("rx", "time", "status"), as.integer)
  data$status = as.logical(data$status)
  data$sex = factor(data$sex, levels = c("f", "m"))

  b = as_data_backend(data)
  b$hash = "_mlr3_survival_rats_"
  TaskSurv$new("rats", b, time = "time", status = "status")
}
mlr-org/mlr3survival documentation built on Oct. 21, 2019, 7:42 p.m.