R/ptd_add_target_column.R

Defines functions ptd_add_target_column

ptd_add_target_column <- function(.data, target) {
  if (is.null(target)) {
    .data$target <- as.double(NA)
  } else if (is.numeric(target)) {
    .data$target <- target
  } else {
    t <- data.frame(f = names(target), target = as.numeric(target))

    .data <- left_join(.data, t, by = "f")
  }

  .data
}

Try the NHSRplotthedots package in your browser

Any scripts or data that you put into this service are public.

NHSRplotthedots documentation built on Nov. 4, 2021, 1:07 a.m.