R/utils_character.R

Defines functions paste_list produce_lines string_sub_expression capitalize

capitalize <- function(x) {
  x <- tolower(x)
  substr(x, 1, 1) <- toupper(substr(x, 1, 1))
  x
}

string_sub_expression <- function(x) {
  x <- gsub("^expression\\(", "", x)
  x <- gsub("\\)$", "", x)
  x
}

produce_lines <- function(x) {
  lines <- unlist(strsplit(as.character(x), split = "\n"))
  if_any(
    length(x),
    paste(lines, collapse = "\n    "),
    tar_deparse_safe(x)
  )
}

paste_list <- function(x) {
  if_any(
    length(x),
    paste0(names(x), ": ", x),
    list()
  )
}

Try the targets package in your browser

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

targets documentation built on Oct. 12, 2023, 5:07 p.m.