← all packages

tidyr

native: 0 functions analysed · 0 typed · 0 untypeable · 0 timed out · 2 entry points (0 typed) · R: 227 definitions, 17 typed strict, 149 gradual, prelude debt 145 · fuzzing: 13 definitions, 0 unsound, 8 accept calls outside their domain · tyr dc7f1a7 · Rsem 7bcb45f · NativeSem 770a1eb · rstt 2b2696f unpinned

R definitions

named top-level definitions
227 / 227 (100.0%)
not blocked by an unbound native symbol
225 / 227 (99.1%)
2 definitions report unbound variable on a native symbol tyr could not bind — the native panel’s loss, arriving here.
typed, gradual
149 / 227 (65.6%)
typed, strict
17 / 227 (7.5%)
145 of the strict failures are a name missing from the prelude.
side
mode
268 / 268

Native functions 2

_tidyr_melt_dataframe unknown entry .Call

called from R, but not defined in src/ (registered under another name, generated, or defined in a dependency)

_tidyr_simplifyPieces unknown entry .Call

called from R, but not defined in src/ (registered under another name, generated, or defined in a dependency)

R definitions 266

R/utils.R

<statement> typed

timing: 0.000 s
source
NULL
R/utils.R:11

reconstruct_tibble untypeabletyped

unbound variable (line 16)
unbound: dplyr::group_vars — a name the prelude does not declare
error detail
name: dplyr::group_vars
gradual mode: typed
((input: any, output: any, ungrouped_vars: any?) -> any)<>
timing: 0.051 s
source
reconstruct_tibble <- function(input, output, ungrouped_vars = character()) {
  if (inherits(input, "grouped_df")) {
    old_groups <- dplyr::group_vars(input)
    new_groups <- intersect(setdiff(old_groups, ungrouped_vars), names(output))
    dplyr::grouped_df(
      output,
      new_groups,
      drop = dplyr::group_by_drop_default(input)
    )
  } else if (inherits(input, "tbl_df")) {
    # Assume name repair carried out elsewhere
    as_tibble(output, .name_repair = "minimal")
  } else {
    output
  }
}
R/utils.R:14

seq_nrow untypeable

untypeable application of base::seq_len (line 31)
error detail
argument: @(INT1<> | null)
failing call: base::seq_len(NULL)
timing: 0.018 s
source
seq_nrow <- function(x) seq_len(nrow(x))
R/utils.R:31

seq_ncol untypeable

untypeable application of base::seq_len (line 32)
error detail
argument: @(INT1<> | null)
failing call: base::seq_len(NULL)
timing: 0.017 s
source
seq_ncol <- function(x) seq_len(ncol(x))
R/utils.R:32

last typed accepts outside

∀'a,'b. (((x: <@"[[", ...>) -> any) & ((x: v('b)<~@"[[", ...>) -> v1('b)<>) & ((x: { 'a }<~@"[[", ...>) -> 'a))<>
timing: 0.095 s
fuzzing: 11 inside (8 ok, 3 error type) · 8 outside (5 rejected, 3 accepted)
type drawn from: (((x: <@"[[", ...>) -> any) & ((x: v('I573)<~@"[[", ...>) -> v1('I573)<>) & ((x: { 'I561 }<~@"[[", ...>) -> 'I561))<>

Accepted outside the domain x: 3

parameterchangecallreturned
xkind:langlast("x" = quote(f(x)))sym
xkind:langlast(quote(f(x)))sym
xkind:nulllast("x" = NULL)null

Other calls inside the domain

callverdicterror
last("x" = list())error_typebase::[[: attempt to select less than one element in integerOneIndex
last(list())error_typebase::[[: attempt to select less than one element in integerOneIndex
last(numeric(0))error_typebase::[[: attempt to select less than one element in integerOneIndex
source
last <- function(x) x[[length(x)]]
R/utils.R:34

tidyr_legacy untypeabletyped

unbound variable (line 67)
unbound: make.unique — a name the prelude does not declare
error detail
name: make.unique
gradual mode: typed
((nms: ""<@"[", ...>, prefix: any?, sep: any?) | (nms: ""<~@"[", ...>, prefix: any?, sep: any?) | (nms: (vec & ~"")<~@"[", ...>, prefix: any?, sep: any?) | (nms: (~"")<@"[", ...>, prefix: any?, sep: any?) | (nms: list<~@"[", ...>, prefix: any?, sep: any?) -> any)<>
timing: 0.461 s
source
tidyr_legacy <- function(nms, prefix = "V", sep = "") {
  if (length(nms) == 0) {
    return(character())
  }
  blank <- nms == ""
  nms[!blank] <- make.unique(nms[!blank], sep = sep)
  new_nms <- setdiff(paste(prefix, seq_along(nms), sep = sep), nms)
  nms[blank] <- new_nms[seq_len(sum(blank))]
  nms
}
R/utils.R:62

check_data_frame skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.002 s
source
check_data_frame <- function(x, ..., arg = caller_arg(x), call = caller_env()) {
  if (!is.data.frame(x)) {
    cli::cli_abort(
      "{.arg {arg}} must be a data frame, not {.obj_type_friendly {x}}.",
      ...,
      call = call
    )
  }
}
R/utils.R:263

tidyr_new_list untypeabletyped

unbound variable (line 101)
unbound: is_list — a name the prelude does not declare
error detail
name: is_list
gradual mode: typed
((x: any) -> any)<>
timing: 0.023 s
source
tidyr_new_list <- function(x) {
  if (!is_list(x)) {
    cli::cli_abort("`x` must be a list.", .internal = TRUE)
  }

  names <- names(x)

  if (is.null(names)) {
    attributes(x) <- NULL
  } else {
    attributes(x) <- list(names = names)
  }

  x
}
R/utils.R:100

tidyr_col_modify untypeabletyped

unbound variable (line 78)
unbound: check_data_frame — one of the package’s own names, itself untyped
error detail
name: check_data_frame
gradual mode: typed
((data: any, cols: { }<~@"[[", ...>) -> any)<>
timing: 0.020 s
source
tidyr_col_modify <- function(data, cols) {
  # Implement from first principles to avoid edge cases in
  # data frame methods for `[<-` and `[[<-`.
  # Assume each element of `cols` has the correct size.

  check_data_frame(data, .internal = TRUE)
  if (!is_list(cols)) {
    cli::cli_abort("`cols` must be a list.", .internal = TRUE)
  }

  size <- vec_size(data)
  data <- tidyr_new_list(data)

  names <- names(cols)

  for (i in seq_along(cols)) {
    name <- names[[i]]
    data[[name]] <- cols[[i]]
  }

  # Assume that we can return a bare data frame that will up restored to
  # a tibble / grouped df as needed elsewhere
  data <- new_data_frame(data, n = size)

  data
}
R/utils.R:73

list_replace_null untypeabletyped

unbound variable (line 137)
unbound: check_dots_empty0 — a name the prelude does not declare
error detail
name: check_dots_empty0
gradual mode: typed
((x: any, sizes: any, ...: any, ptype: any?, size: any?) -> { x: any, sizes: any }<>)<>
timing: 0.067 s
source
list_replace_null <- function(x, sizes, ..., ptype = NULL, size = 1L) {
  check_dots_empty0(...)

  if (!vec_is_list(x)) {
    cli::cli_abort("`x` must be a list.", .internal = TRUE)
  }
  if (is_list_of(x)) {
    cli::cli_abort(
      "`x` can't be a list-of. Unclass first and provide `ptype`.",
      .internal = TRUE
    )
  }

  if (vec_any_missing(x)) {
    null <- vec_detect_missing(x)
    null <- which(null)

    if (is_null(ptype)) {
      replacement <- list(unspecified(size))
    } else {
      replacement <- list(vec_init(ptype, size))
    }

    x <- vec_assign(x, null, replacement)

    if (size != 0L) {
      sizes <- vec_assign(sizes, null, size)
    }
  }

  list(x = x, sizes = sizes)
}
R/utils.R:136

list_replace_empty_typed untypeabletyped

unbound variable (line 196)
unbound: check_dots_empty0 — a name the prelude does not declare
error detail
name: check_dots_empty0
gradual mode: typed
((x: any, sizes: any, ...: any, ptype: any?, size: any?) -> { x: any, sizes: any }<>)<>
timing: 0.075 s
source
list_replace_empty_typed <- function(x, sizes, ..., ptype = NULL, size = 1L) {
  check_dots_empty0(...)

  if (!vec_is_list(x)) {
    cli::cli_abort("`x` must be a list.", .internal = TRUE)
  }
  if (is_list_of(x)) {
    cli::cli_abort("`x` can't be a list-of. Unclass first.", .internal = TRUE)
  }
  if (size == 0L) {
    cli::cli_abort("`size` should never be 0.", .internal = TRUE)
  }

  empty <- sizes == 0L

  if (any(empty)) {
    empty <- which(empty)

    if (is_null(ptype)) {
      replacement <- map(vec_slice(x, empty), function(elt) vec_init(elt, size))
    } else {
      replacement <- list(vec_init(ptype, size))
    }

    x <- vec_assign(x, empty, replacement)
    sizes <- vec_assign(sizes, empty, size)
  }

  list(x = x, sizes = sizes)
}
R/utils.R:195

list_all_vectors2 untypeabletyped

unbound variable (line 228)
unbound: vec_any_missing — a name the prelude does not declare
error detail
name: vec_any_missing
gradual mode: typed
((x: any) -> any)<>
timing: 0.009 s
source
list_all_vectors2 <- function(x) {
  if (vec_any_missing(x)) {
    missing <- vec_detect_missing(x)
    x <- vec_slice(x, !missing)
  }
  list_all_vectors(x)
}
R/utils.R:227

list_of_ptype untypeabletyped

unbound variable (line 240)
unbound: vec_set_names — a name the prelude does not declare
error detail
name: vec_set_names
gradual mode: typed
((x: any with { ptype: any, any }) -> any)<>
timing: 0.014 s
source
list_of_ptype <- function(x) {
  ptype <- attr(x, "ptype", exact = TRUE)

  # ptypes should always be unnamed, but this isn't guaranteed right now.
  # See https://github.com/r-lib/vctrs/pull/1020#discussion_r411327472
  ptype <- vec_set_names(ptype, NULL)

  ptype
}
R/utils.R:235

apply_names_sep typed any: outer, inner, names_sep accepts outside

((outer: any, inner: any, names_sep: any) -> CHR<>)<>
timing: 0.066 s
fuzzing: 8 inside (3 ok, 5 error type) · 8 outside (6 rejected, 2 accepted)

Accepted outside the domain inner: 2

parameterchangecallreturned
innerdropapply_names_sep(quote(f(x)), NULL)(CHR & ~vec1)<> with { }
innerdropapply_names_sep(function(...) c(0L, -1L), NULL)(CHR & ~vec1)<> with { }

Other calls inside the domain

callverdicterror
apply_names_sep(quote(f(x)), as.name("x"), "names_sep" = function(...) list())error_typebase::paste0: cannot coerce type 'closure' to vector of type 'character'
apply_names_sep("outer" = function(...) as.name("x"), "inner" = as.name("x"), "names_sep" = function(...) function(...) as.name("x"))error_typebase::paste0: cannot coerce type 'closure' to vector of type 'character'
apply_names_sep(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), list(new.env(), quote(f(x))), as.name("x"))error_typebase::paste0: cannot coerce type 'externalptr' to vector of type 'character'
apply_names_sep(logical(0), function(...) as.name("x"), new.env())error_typebase::paste0: environments cannot be coerced to other types
apply_names_sep(function(...) c(0L, -1L), as.name("x"), NULL)error_typebase::paste0: cannot coerce type 'closure' to vector of type 'character'
source
apply_names_sep <- function(outer, inner, names_sep) {
  # Need to avoid `paste0()` recycling issue. Not using `vec_paste0()`
  # because that is too slow to be applied to each element (#1427).
  # `outer` and `names_sep` are required to be length 1,
  # so we only need to check `inner`.
  if (length(inner) == 0L) {
    character()
  } else {
    paste0(outer, names_sep, inner)
  }
}
R/utils.R:245

vec_paste0 untypeabletyped

unbound variable (line 259)
unbound: vec_recycle_common — a name the prelude does not declare
error detail
name: vec_recycle_common
gradual mode: typed
((...: any) -> any)<>
timing: 0.025 s
source
vec_paste0 <- function(...) {
  # Use tidyverse recycling rules to avoid size zero recycling bugs
  args <- vec_recycle_common(...)
  exec(paste0, !!!args)
}
R/utils.R:257

check_unique_names untypeabletyped

unbound variable (line 273)
unbound: caller_arg — a name the prelude does not declare
error detail
name: caller_arg
gradual mode: typed
((x: any, arg: any?, call: any?) -> any)<>
timing: 0.050 s
source
check_unique_names <- function(x, arg = caller_arg(x), call = caller_env()) {
  if (length(x) > 0L && !is_named(x)) {
    cli::cli_abort("All elements of {.arg {arg}} must be named.", call = call)
  }
  if (vec_duplicate_any(names(x))) {
    cli::cli_abort("The names of {.arg {arg}} must be unique.", call = call)
  }
}
R/utils.R:273

check_list_of_ptypes untypeabletyped

unbound variable (line 285)
unbound: caller_arg — a name the prelude does not declare
error detail
name: caller_arg
gradual mode: typed
∀'a. ((x: 'a & null, names: any, arg: any?, call: any?) | (x: 'a \ null, names: @('a \ null) -> empty, arg: any?, call: any?) -> any)<>
timing: 0.046 s
source
check_list_of_ptypes <- function(
  x,
  names,
  arg = caller_arg(x),
  call = caller_env()
) {
  if (is.null(x)) {
    set_names(list(), character())
  } else if (vec_is(x) && vec_is_empty(x)) {
    rep_named(names, list(x))
  } else if (vec_is_list(x)) {
    check_unique_names(x, arg = arg, call = call)

    # Silently drop user supplied names not found in the data
    x[intersect(names(x), names)]
  } else {
    cli::cli_abort(
      "{.arg {arg}} must be `NULL`, an empty ptype, or a named list of ptypes.",
      call = call
    )
  }
}
R/utils.R:282

check_list_of_functions untypeable

unbound variable (line 308)
unbound: caller_arg — a name the prelude does not declare
error detail
name: caller_arg
timing: 0.090 s
source
check_list_of_functions <- function(
  x,
  names,
  arg = caller_arg(x),
  call = caller_env()
) {
  if (is.null(x)) {
    x <- set_names(list(), character())
  } else if (is.function(x) || is_formula(x)) {
    x <- rep_named(names, list(x))
  } else if (!vec_is_list(x)) {
    cli::cli_abort(
      "{.arg {arg}} must be `NULL`, a function, or a named list of functions.",
      call = call
    )
  }

  check_unique_names(x, arg = arg, call = call)
  x_names <- names(x)

  for (i in seq_along(x)) {
    x[[i]] <- as_function(
      x[[i]],
      arg = glue("{arg}${x_names[[i]]}"),
      call = call
    )
  }

  # Silently drop user supplied names not found in the data
  x <- x[intersect(x_names, names)]

  x
}
R/utils.R:305

check_list_of_bool untypeabletyped

unbound variable (line 342)
unbound: caller_arg — a name the prelude does not declare
error detail
name: caller_arg
gradual mode: typed
∀'a. ((x: 'a, names: @('a) -> empty, arg: any?, call: any?) -> any)<>
timing: 0.026 s
source
check_list_of_bool <- function(
  x,
  names,
  arg = caller_arg(x),
  call = caller_env()
) {
  if (is_bool(x)) {
    rep_named(names, x)
  } else if (vec_is_list(x)) {
    check_unique_names(x, arg = arg, call = call)
    x[intersect(names(x), names)]
  } else {
    cli::cli_abort(
      "{.arg {arg}} must be a list or a single `TRUE` or `FALSE`.",
      call = call
    )
  }
}
R/utils.R:339

with_indexed_errors skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
with_indexed_errors <- function(
  expr,
  message,
  ...,
  .error_call = caller_env(),
  .frame = caller_env()
) {
  try_fetch(
    expr,
    purrr_error_indexed = function(cnd) {
      message <- message(cnd)
      abort(
        message,
        ...,
        call = .error_call,
        parent = cnd$parent,
        .frame = .frame
      )
    }
  )
}
R/utils.R:358

int_max typed fuzz ok

∀'a. (((x: dbl, default: 'a?) -> dbl1 | 'a)&((x: int, default: 'a?) -> (DBL1<> | INT1) | 'a))<>
timing: 0.124 s
fuzzing: 19 inside (15 ok, 4 error type) · 8 outside (8 rejected)
type drawn from: (((x: dbl, default: 'default?) -> dbl1 | 'default) & ((x: int, default: 'default?) -> (DBL1<> | INT1) | 'default))<>

Other calls inside the domain

callverdicterror
int_max("x" = as.raw(c(0, 255)))error_typebase::max: invalid 'type' (raw) of argument
int_max(as.raw(c(255)), "default" = NA_complex_)error_typebase::max: invalid 'type' (raw) of argument
int_max(as.raw(c(0)), "default" = as.raw(c(0)))error_typebase::max: invalid 'type' (raw) of argument
int_max(as.raw(c(0)), "default" = as.name("x"))error_typebase::max: invalid 'type' (raw) of argument
source
int_max <- function(x, default = -Inf) {
  if (length(x) == 0) {
    default
  } else {
    max(x)
  }
}
R/utils.R:380
R/import-standalone-obj-type.R

.rlang_as_friendly_type skipped

error detail
File "Rsem/lang/PAst.ml", line 145, characters 25-31: Assertion failed
timing: 0.000 s
source
.rlang_as_friendly_type <- function(type) {
  switch(
    type,

    list = "a list",

    NULL = "`NULL`",
    environment = "an environment",
    externalptr = "a pointer",
    weakref = "a weak reference",
    S4 = "an S4 object",

    name = ,
    symbol = "a symbol",
    language = "a call",
    pairlist = "a pairlist node",
    expression = "an expression vector",

    char = "an internal string",
    promise = "an internal promise",
    ... = "an internal dots object",
    any = "an internal `any` object",
    bytecode = "an internal bytecode object",

    primitive = ,
    builtin = ,
    special = "a primitive function",
    closure = "a function",

    type
  )
}
R/import-standalone-obj-type.R:231

.rlang_stop_unexpected_typeof untypeabletyped

unbound variable (line 264)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((x: any, call: any?) -> any)<>
timing: 0.008 s
source
.rlang_stop_unexpected_typeof <- function(x, call = caller_env()) {
  abort(
    sprintf("Unexpected type <%s>.", typeof(x)),
    call = call
  )
}
R/import-standalone-obj-type.R:264

vec_type_friendly untypeabletimeout

unbound variable (line 177)
unbound: is_vector — a name the prelude does not declare
error detail
name: is_vector
gradual mode: timeout
timing: 0.482 s
source
vec_type_friendly <- function(x, length = FALSE) {
  if (!is_vector(x)) {
    abort("`x` must be a vector.")
  }
  type <- typeof(x)
  n_dim <- length(dim(x))

  add_length <- function(type) {
    if (length && !n_dim) {
      paste0(type, sprintf(" of length %s", length(x)))
    } else {
      type
    }
  }

  if (type == "list") {
    if (n_dim < 2) {
      return(add_length("a list"))
    } else if (is.data.frame(x)) {
      return("a data frame")
    } else if (n_dim == 2) {
      return("a list matrix")
    } else {
      return("a list array")
    }
  }

  type <- switch(
    type,
    logical = "a logical %s",
    integer = "an integer %s",
    numeric = ,
    double = "a double %s",
    complex = "a complex %s",
    character = "a character %s",
    raw = "a raw %s",
    type = paste0("a ", type, " %s")
  )

  if (n_dim < 2) {
    kind <- "vector"
  } else if (n_dim == 2) {
    kind <- "matrix"
  } else {
    kind <- "array"
  }
  out <- sprintf(type, kind)

  if (n_dim >= 2) {
    out
  } else {
    add_length(out)
  }
}
R/import-standalone-obj-type.R:176

obj_type_friendly skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.003 s
source
obj_type_friendly <- function(x, value = TRUE) {
  if (is_missing(x)) {
    return("absent")
  }

  if (is.object(x)) {
    if (inherits(x, "quosure")) {
      type <- "quosure"
    } else {
      type <- class(x)[[1L]]
    }
    return(sprintf("a <%s> object", type))
  }

  if (!is_vector(x)) {
    return(.rlang_as_friendly_type(typeof(x)))
  }

  n_dim <- length(dim(x))

  if (!n_dim) {
    if (!is_list(x) && length(x) == 1) {
      if (is_na(x)) {
        return(switch(
          typeof(x),
          logical = "`NA`",
          integer = "an integer `NA`",
          double =
            if (is.nan(x)) {
              "`NaN`"
            } else {
              "a numeric `NA`"
            },
          complex = "a complex `NA`",
          character = "a character `NA`",
          .rlang_stop_unexpected_typeof(x)
        ))
      }

      show_infinites <- function(x) {
        if (x > 0) {
          "`Inf`"
        } else {
          "`-Inf`"
        }
      }
      str_encode <- function(x, width = 30, ...) {
        if (nchar(x) > width) {
          x <- substr(x, 1, width - 3)
          x <- paste0(x, "...")
        }
        encodeString(x, ...)
      }

      if (value) {
        if (is.numeric(x) && is.infinite(x)) {
          return(show_infinites(x))
        }

        if (is.numeric(x) || is.complex(x)) {
          number <- as.character(round(x, 2))
          what <- if (is.complex(x)) "the complex number" else "the number"
          return(paste(what, number))
        }

        return(switch(
          typeof(x),
          logical = if (x) "`TRUE`" else "`FALSE`",
          character = {
            what <- if (nzchar(x)) "the string" else "the empty string"
            paste(what, str_encode(x, quote = "\""))
          },
          raw = paste("the raw value", as.character(x)),
          .rlang_stop_unexpected_typeof(x)
        ))
      }

      return(switch(
        typeof(x),
        logical = "a logical value",
        integer = "an integer",
        double = if (is.infinite(x)) show_infinites(x) else "a number",
        complex = "a complex number",
        character = if (nzchar(x)) "a string" else "\"\"",
        raw = "a raw value",
        .rlang_stop_unexpected_typeof(x)
      ))
    }

    if (length(x) == 0) {
      return(switch(
        typeof(x),
        logical = "an empty logical vector",
        integer = "an empty integer vector",
        double = "an empty numeric vector",
        complex = "an empty complex vector",
        character = "an empty character vector",
        raw = "an empty raw vector",
        list = "an empty list",
        .rlang_stop_unexpected_typeof(x)
      ))
    }
  }

  vec_type_friendly(x)
}
R/import-standalone-obj-type.R:69

obj_type_oo untypeabletyped

unbound variable (line 277)
unbound: is.object — a name the prelude does not declare
error detail
name: is.object
gradual mode: typed
((x: any) -> "R6"<> | "S3"<> | "S4"<> | "S7"<> | "bare"<>)<>
timing: 1.76 s
source
obj_type_oo <- function(x) {
  if (!is.object(x)) {
    return("bare")
  }

  class <- inherits(x, c("R6", "S7_object"), which = TRUE)

  if (class[[1]]) {
    "R6"
  } else if (class[[2]]) {
    "S7"
  } else if (isS4(x)) {
    "S4"
  } else {
    "S3"
  }
}
R/import-standalone-obj-type.R:276

oxford_comma typed any: final accepts outside

∀'a,'b. ((chr: CHR<> | 'a & (CHR | v('b))<~@"[", ...>, sep: (vec1 | null)?, final: any?) -> CHR<> | (CHR | v('b))<~@"[", ...> & 'a)<>
timing: 0.917 s
fuzzing: 20 inside (15 ok, 5 error type) · 8 outside (3 rejected, 3 accepted, 2 not forced)
type drawn from: ((chr: CHR<> | 'chr & (CHR | v('I1085))<~@"[", ...>, sep: (vec1 | null)?, final: any?) -> CHR<> | (CHR | v('I1085))<~@"[", ...> & 'chr)<>

Accepted outside the domain chr: 3

parameterchangecallreturned
chrkind:nulloxford_comma(NULL, -2.5, as.name("x"))null
chrkind:symoxford_comma(as.name("x"), as.raw(c(255)), NULL)sym
chrwrapoxford_comma(list(c("", "NA"))){ (CHR & ~vec1)<> with { } }<> with { }

Other calls inside the domain

callverdicterror
oxford_comma(c("x y", "NA"), as.raw(c(255)), NULL)error_typebase::paste: invalid 'collapse' argument
oxford_comma(c("x y", ""), as.raw(c(0)))error_typebase::paste: invalid 'collapse' argument
oxford_comma(c("x y", ""), 1000000L, "final" = quote(f(x)))error_typebase::paste: invalid 'collapse' argument
oxford_comma(c(NA_character_, "é"), "sep" = complex(real = 1, imaginary = -2), "final" = as.name("x"))error_typebase::paste: invalid 'collapse' argument
oxford_comma("chr" = c("", "x y"), "final" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_typebase::paste0: cannot coerce type 'externalptr' to vector of type 'character'
source
oxford_comma <- function(chr, sep = ", ", final = "or") {
  n <- length(chr)

  if (n < 2) {
    return(chr)
  }

  head <- chr[seq_len(n - 1)]
  last <- chr[n]

  head <- paste(head, collapse = sep)

  # Write a or b. But a, b, or c.
  if (n > 2) {
    paste0(head, sep, final, " ", last)
  } else {
    paste0(head, " ", final, " ", last)
  }
}
R/import-standalone-obj-type.R:344

stop_input_type skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
stop_input_type <- function(x,
                            what,
                            ...,
                            allow_na = FALSE,
                            allow_null = FALSE,
                            show_value = TRUE,
                            arg = caller_arg(x),
                            call = caller_env()) {
  # From standalone-cli.R
  cli <- env_get_list(
    nms = c("format_arg", "format_code"),
    last = topenv(),
    default = function(x) sprintf("`%s`", x),
    inherit = TRUE
  )

  if (allow_na) {
    what <- c(what, cli$format_code("NA"))
  }
  if (allow_null) {
    what <- c(what, cli$format_code("NULL"))
  }
  if (length(what)) {
    what <- oxford_comma(what)
  }
  if (inherits(arg, "AsIs")) {
    format_arg <- identity
  } else {
    format_arg <- cli$format_arg
  }

  message <- sprintf(
    "%s must be %s, not %s.",
    format_arg(arg),
    what,
    obj_type_friendly(x, value = show_value)
  )

  abort(message, ..., call = call, arg = arg)
}
R/import-standalone-obj-type.R:303
R/import-standalone-types-check.R

.standalone_types_check_dot_call untypeabletyped

unbound variable (line 66)
unbound: .Call — a name the prelude does not declare
error detail
name: .Call
gradual mode: typed
any
timing: 0.000 s
source
.standalone_types_check_dot_call <- .Call
R/import-standalone-types-check.R:66

check_bool skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_bool <- function(x,
                       ...,
                       allow_na = FALSE,
                       allow_null = FALSE,
                       arg = caller_arg(x),
                       call = caller_env()) {
  if (!missing(x) && .standalone_types_check_dot_call(ffi_standalone_is_bool_1.0.7, x, allow_na, allow_null)) {
    return(invisible(NULL))
  }

  stop_input_type(
    x,
    c("`TRUE`", "`FALSE`"),
    ...,
    allow_na = allow_na,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:68

.rlang_check_is_string untypeabletyped

unbound variable (line 123)
unbound: is_string — a name the prelude does not declare
error detail
name: is_string
gradual mode: typed
((x: any, allow_empty: any, allow_na: any, allow_null: any) -> ff<> | tt<>)<>
timing: 0.137 s
source
.rlang_check_is_string <- function(x,
                                   allow_empty,
                                   allow_na,
                                   allow_null) {
  if (is_string(x)) {
    if (allow_empty || !is_string(x, "")) {
      return(TRUE)
    }
  }

  if (allow_null && is_null(x)) {
    return(TRUE)
  }

  if (allow_na && (identical(x, NA) || identical(x, na_chr))) {
    return(TRUE)
  }

  FALSE
}
R/import-standalone-types-check.R:119

check_string skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_string <- function(x,
                         ...,
                         allow_empty = TRUE,
                         allow_na = FALSE,
                         allow_null = FALSE,
                         arg = caller_arg(x),
                         call = caller_env()) {
  if (!missing(x)) {
    is_string <- .rlang_check_is_string(
      x,
      allow_empty = allow_empty,
      allow_na = allow_na,
      allow_null = allow_null
    )
    if (is_string) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a single string",
    ...,
    allow_na = allow_na,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:89

check_name skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_name <- function(x,
                       ...,
                       allow_null = FALSE,
                       arg = caller_arg(x),
                       call = caller_env()) {
  if (!missing(x)) {
    is_string <- .rlang_check_is_string(
      x,
      allow_empty = FALSE,
      allow_na = FALSE,
      allow_null = allow_null
    )
    if (is_string) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a valid name",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:140

IS_NUMBER_true typed

0.<>
timing: 0.003 s
source
IS_NUMBER_true <- 0
R/import-standalone-types-check.R:168

IS_NUMBER_false typed

1.<>
timing: 0.003 s
source
IS_NUMBER_false <- 1
R/import-standalone-types-check.R:169

IS_NUMBER_oob typed

2.<>
timing: 0.003 s
source
IS_NUMBER_oob <- 2
R/import-standalone-types-check.R:170

.stop_not_number skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
.stop_not_number <- function(x,
                             ...,
                             exit_code,
                             allow_decimal,
                             min,
                             max,
                             allow_na,
                             allow_null,
                             arg,
                             call) {
  if (allow_decimal) {
    what <- "a number"
  } else {
    what <- "a whole number"
  }

  if (exit_code == IS_NUMBER_oob) {
    min <- min %||% -Inf
    max <- max %||% Inf

    if (min > -Inf && max < Inf) {
      what <- sprintf("%s between %s and %s", what, min, max)
    } else if (x < min) {
      what <- sprintf("%s larger than or equal to %s", what, min)
    } else if (x > max) {
      what <- sprintf("%s smaller than or equal to %s", what, max)
    } else {
      abort("Unexpected state in OOB check", .internal = TRUE)
    }
  }

  stop_input_type(
    x,
    what,
    ...,
    allow_na = allow_na,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:248

check_number_decimal skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_number_decimal <- function(x,
                                 ...,
                                 min = NULL,
                                 max = NULL,
                                 allow_infinite = TRUE,
                                 allow_na = FALSE,
                                 allow_null = FALSE,
                                 arg = caller_arg(x),
                                 call = caller_env()) {
  if (missing(x)) {
    exit_code <- IS_NUMBER_false
  } else if (0 == (exit_code <- .standalone_types_check_dot_call(
    ffi_standalone_check_number_1.0.7,
    x,
    allow_decimal = TRUE,
    min,
    max,
    allow_infinite,
    allow_na,
    allow_null
  ))) {
    return(invisible(NULL))
  }

  .stop_not_number(
    x,
    ...,
    exit_code = exit_code,
    allow_decimal = TRUE,
    min = min,
    max = max,
    allow_na = allow_na,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:172

check_number_whole skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_number_whole <- function(x,
                               ...,
                               min = NULL,
                               max = NULL,
                               allow_infinite = FALSE,
                               allow_na = FALSE,
                               allow_null = FALSE,
                               arg = caller_arg(x),
                               call = caller_env()) {
  if (missing(x)) {
    exit_code <- IS_NUMBER_false
  } else if (0 == (exit_code <- .standalone_types_check_dot_call(
    ffi_standalone_check_number_1.0.7,
    x,
    allow_decimal = FALSE,
    min,
    max,
    allow_infinite,
    allow_na,
    allow_null
  ))) {
    return(invisible(NULL))
  }

  .stop_not_number(
    x,
    ...,
    exit_code = exit_code,
    allow_decimal = FALSE,
    min = min,
    max = max,
    allow_na = allow_na,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:210

check_symbol skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_symbol <- function(x,
                         ...,
                         allow_null = FALSE,
                         arg = caller_arg(x),
                         call = caller_env()) {
  if (!missing(x)) {
    if (is_symbol(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a symbol",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:290

check_arg skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_arg <- function(x,
                      ...,
                      allow_null = FALSE,
                      arg = caller_arg(x),
                      call = caller_env()) {
  if (!missing(x)) {
    if (is_symbol(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "an argument name",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:315

check_call skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_call <- function(x,
                       ...,
                       allow_null = FALSE,
                       arg = caller_arg(x),
                       call = caller_env()) {
  if (!missing(x)) {
    if (is_call(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a defused call",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:340

check_environment skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_environment <- function(x,
                              ...,
                              allow_null = FALSE,
                              arg = caller_arg(x),
                              call = caller_env()) {
  if (!missing(x)) {
    if (is_environment(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "an environment",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:365

check_function skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_function <- function(x,
                           ...,
                           allow_null = FALSE,
                           arg = caller_arg(x),
                           call = caller_env()) {
  if (!missing(x)) {
    if (is_function(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a function",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:390

check_closure skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_closure <- function(x,
                          ...,
                          allow_null = FALSE,
                          arg = caller_arg(x),
                          call = caller_env()) {
  if (!missing(x)) {
    if (is_closure(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "an R function",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:415

check_formula skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_formula <- function(x,
                          ...,
                          allow_null = FALSE,
                          arg = caller_arg(x),
                          call = caller_env()) {
  if (!missing(x)) {
    if (is_formula(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a formula",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:440

check_character skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_character <- function(x,
                            ...,
                            allow_na = TRUE,
                            allow_null = FALSE,
                            arg = caller_arg(x),
                            call = caller_env()) {

  if (!missing(x)) {
    if (is_character(x)) {
      if (!allow_na && any(is.na(x))) {
        abort(
          sprintf("`%s` can't contain NA values.", arg),
          arg = arg,
          call = call
        )
      }

      return(invisible(NULL))
    }

    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a character vector",
    ...,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:470

check_logical skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_logical <- function(x,
                          ...,
                          allow_null = FALSE,
                          arg = caller_arg(x),
                          call = caller_env()) {
  if (!missing(x)) {
    if (is_logical(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a logical vector",
    ...,
    allow_na = FALSE,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:505

check_data_frame skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
check_data_frame <- function(x,
                             ...,
                             allow_null = FALSE,
                             arg = caller_arg(x),
                             call = caller_env()) {
  if (!missing(x)) {
    if (is.data.frame(x)) {
      return(invisible(NULL))
    }
    if (allow_null && is_null(x)) {
      return(invisible(NULL))
    }
  }

  stop_input_type(
    x,
    "a data frame",
    ...,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}
R/import-standalone-types-check.R:530
R/append.R

df_append untypeable

unbound variable (line 24)
unbound: vec_size — a name the prelude does not declare
error detail
name: vec_size
timing: 0.058 s
source
df_append <- function(x, y, after = NULL, remove = FALSE) {
  size <- vec_size(x)
  row_names <- .row_names_info(x, type = 0L)

  x <- tidyr_new_list(x)
  y <- tidyr_new_list(y)

  x_names <- names(x)
  y_names <- names(y)

  n <- length(x)

  if (is.null(after)) {
    after <- n
  } else if (is.character(after)) {
    after <- match(after, x_names)
  }

  # r-lib/rlang#1702
  check_number_whole(after, min = 0, max = as.numeric(n), .internal = TRUE)

  if (remove) {
    lhs <- seq2(1L, after - 1L)
  } else {
    lhs <- seq2(1L, after)
  }

  rhs <- seq2(after + 1L, n)

  # Prefer `y` if names are duplicated
  lhs <- setdiff(x_names[lhs], y_names)
  rhs <- setdiff(x_names[rhs], y_names)

  out <- vec_c(x[lhs], y, x[rhs])
  out <- new_data_frame(out, n = size, row.names = row_names)

  out
}
R/append.R:23
R/chop.R

col_chop untypeabletyped

unbound variable (line 98)
unbound: vec_ptype — a name the prelude does not declare
error detail
name: vec_ptype
gradual mode: typed
((x: any, indices: any) -> any)<>
timing: 0.004 s
source
col_chop <- function(x, indices) {
  ptype <- vec_ptype(x)

  out <- vec_chop(x, indices)
  out <- new_list_of(out, ptype)

  out
}
R/chop.R:97

chop untypeabletyped

unbound variable (line 68)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
gradual mode: typed
((data: any, cols: any, ...: any, error_call: any?) -> any)<>
timing: 0.017 s
source
chop <- function(data, cols, ..., error_call = current_env()) {
  check_dots_empty0(...)
  check_data_frame(data, call = error_call)
  check_required(cols, call = error_call)

  cols <- tidyselect::eval_select(
    expr = enquo(cols),
    data = data,
    allow_rename = FALSE,
    error_call = error_call
  )

  cols <- tidyr_new_list(data[cols])
  keys <- data[setdiff(names(data), names(cols))]

  info <- vec_group_loc(keys)
  keys <- info$key
  indices <- info$loc

  size <- vec_size(keys)

  cols <- map(cols, col_chop, indices = indices)
  cols <- new_data_frame(cols, n = size)

  out <- vec_cbind(keys, cols, .error_call = error_call)

  reconstruct_tibble(data, out)
}
R/chop.R:68

unchop_finalize typed any: x_nulls accepts outside

∀'a,'b. ((x: 'b, sizes: 'a, x_nulls: any, keep_empty: tt) -> { x: 'b, sizes: 'a }<>)<>
gradual mode: typed
∀'a,'b. (((x: 'b, sizes: 'a, x_nulls: any, keep_empty: tt) -> { x: 'b, sizes: 'a }<>)&((x: any, sizes: any, x_nulls: any, keep_empty: any) -> { x: any, sizes: any }<>))<>
timing: 0.208 s
fuzzing: 20 inside (20 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: ((x: 'x, sizes: 'sizes, x_nulls: any, keep_empty: tt) -> { x: 'x, sizes: 'sizes }<>)<>

Accepted outside the domain x: 1

parameterchangecallreturned
xdropunchop_finalize(complex(0), new.env(), "keep_empty" = TRUE){ x: (CLX & ~vec1)<> with { }, sizes: env<> with { } }<> with { names: (CHR & ~vec1)<> with { } }
source
unchop_finalize <- function(x, sizes, x_nulls, keep_empty) {
  if (keep_empty) {
    return(list(x = x, sizes = sizes))
  }

  # If !keep_empty, `NULL` elements were temporarily given size 1L and
  # converted to a size 1 missing equivalent for recycling. However, if the
  # entire row was made up of `NULL`s, then we need to adjust the size back to
  # 0L and convert back to `NULL`s since that row should be dropped.
  null_row <- reduce(x_nulls, `&`)

  if (any(null_row)) {
    sizes[null_row] <- 0L
    x <- vec_assign(x, null_row, vec_init(x, n = 1L))
  }

  list(x = x, sizes = sizes)
}
R/chop.R:353

unchop_sizes2 typed any: error_call accepts outside

∀`a. ((x: { }<@"[", @"[[", `a>, y: { }<~@"[", ...>, error_call: any) -> { }<@"[", @"[[", `a>)<>
gradual mode: typed
∀'a,'b,'c,`a,`b. (((x: ((CHR | CLX | LGL | RAW) & v('b))<~@"[", ~@"[[", . | `b>, y: ((CHR | CLX | LGL | RAW) & v('b))<@"[[", ~@"[", ...>, error_call: any) | (x: ((CHR | CLX | LGL | RAW) & v('b))<~@"[", ~@"[[", . | `b>, y: ((CHR | CLX | LGL | RAW) & v('b))<~@"[", ~@"[[", ...>, error_call: any) -> ((CHR | CLX | LGL | RAW) & v('b))<~@"[", ~@"[[", . | `b>) & ((x: v('b)<~@"[", ~@"[[", . | `b>, y: v('b)<@"[[", ~@"[", ...>, error_call: any) | (x: v('b)<~@"[", ~@"[[", . | `b>, y: v('b)<~@"[", ~@"[[", ...>, error_call: any) -> v('b)<~@"[", ~@"[[", . | `b>) & ((x: x1<@"[", @"[[", `a>, y: x1<@"[[", ~@"[", ...>, error_call: any) -> x1<@"[", @"[[", `a>) & ((x: x2<@"[", @"[[", `a>, y: x2<~@"[", ~@"[[", ...>, error_call: any) -> x2<@"[", @"[[", `a>) & ((x: { }<@"[", @"[[", `a>, y: { }<~@"[", ...>, error_call: any) -> { }<@"[", @"[[", `a>))<> where x1 = s({ 'a & x1<@"[", @"[[", `a> }) and x2 = s({ 'c & 'a & x2<@"[", @"[[", `a> })
timing: 3.53 s
fuzzing: 8 inside (8 ok) · 8 outside (2 rejected, 6 accepted)
type drawn from: ((x: { }<@"[", @"[[", `I178>, y: { }<~@"[", ...>, error_call: any) -> { }<@"[", @"[[", `I178>)<>

Accepted outside the domain error_call: 2, x: 2, y: 2

parameterchangecallreturned
error_calldropunchop_sizes2("x" = list(), "y" = list()){ }<> with { }
error_calldropunchop_sizes2(list(), "y" = list()){ }<> with { }
xkind:dblunchop_sizes2("x" = 1.5, "y" = list(), "error_call" = list(NA_integer_))(^DBL1 \ (..))<> with { }
xkind:langunchop_sizes2(quote(f(x)), list(), "error_call" = list())lang<> with { }
ydropunchop_sizes2(list(), quote(f(x))){ }<> with { }
ykind:chrunchop_sizes2(list(), "fuzz", "error_call" = as.raw(c(255))){ }<> with { }
source
unchop_sizes2 <- function(x, y, error_call) {
  # Standard tidyverse recycling rules, just vectorized.

  # Recycle `x` values with `y`
  x_one <- x == 1L
  if (any(x_one)) {
    x[x_one] <- y[x_one]
  }

  # Recycle `y` values with `x`.
  # Only necessary to be able to check for incompatibilities.
  y_one <- y == 1L
  if (any(y_one)) {
    y[y_one] <- x[y_one]
  }

  # Check for incompatibilities
  incompatible <- x != y
  if (any(incompatible)) {
    row <- which(incompatible)[[1]]
    x <- x[[row]]
    y <- y[[row]]
    cli::cli_abort(
      "In row {row}, can't recycle input of size {x} to size {y}.",
      call = error_call
    )
  }

  x
}
R/chop.R:322

df_unchop untypeable

unbound variable (line 178)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
timing: 3.39 s
source
df_unchop <- function(
  x,
  ...,
  ptype = NULL,
  keep_empty = FALSE,
  error_call = caller_env()
) {
  check_dots_empty()

  ptype <- check_list_of_ptypes(ptype, names = names(x), call = error_call)

  size <- vec_size(x)

  # Avoid any data frame subclass method dispatch
  x <- new_data_frame(x, n = size)

  width <- length(x)
  x_names <- names(x)

  seq_len_width <- seq_len(width)
  seq_len_size <- seq_len(size)

  if (width == 0L) {
    # Algorithm requires >=1 columns
    out <- list(loc = seq_len_size, val = x)
    out <- new_data_frame(out, n = size)
    return(out)
  }

  x_ptypes <- map2(x, x_names, function(col, name) {
    ptype[[name]] %||% list_of_ptype(col)
  })

  x_is_list <- map_lgl(x, vec_is_list)

  x_sizes <- vector("list", length = width)
  x_nulls <- vector("list", length = width)

  for (i in seq_len_width) {
    col <- x[[i]]
    col_name <- x_names[[i]]
    col_ptype <- x_ptypes[[i]]
    col_is_list <- x_is_list[[i]]

    if (!col_is_list) {
      # Optimize rare non list-cols
      x_sizes[[i]] <- vec_rep(1L, size)
      x_nulls[[i]] <- vec_rep(FALSE, size)
      next
    }

    col <- tidyr_new_list(col)
    col_sizes <- list_sizes(col)
    col_nulls <- vec_detect_missing(col)

    # Always replace `NULL` elements with size 1 missing equivalent for recycling.
    # These will be reset to `NULL` in `unchop_finalize()` if the
    # entire row was missing and `keep_empty = FALSE`.
    info <- list_replace_null(col, col_sizes, ptype = col_ptype)
    col <- info$x
    col_sizes <- info$sizes

    if (keep_empty) {
      info <- list_replace_empty_typed(col, col_sizes, ptype = col_ptype)
      col <- info$x
      col_sizes <- info$sizes
    }

    x[[i]] <- col
    x_sizes[[i]] <- col_sizes
    x_nulls[[i]] <- col_nulls
  }

  sizes <- reduce(x_sizes, unchop_sizes2, error_call = error_call)

  info <- unchop_finalize(x, sizes, x_nulls, keep_empty)
  x <- info$x
  sizes <- info$sizes

  out_loc <- vec_rep_each(seq_len_size, sizes)

  out_size <- sum(sizes)
  out_cols <- vector("list", length = width)

  for (i in seq_len_width) {
    col <- x[[i]]
    col_name <- x_names[[i]]
    col_ptype <- x_ptypes[[i]]
    col_is_list <- x_is_list[[i]]
    col_sizes <- x_sizes[[i]]

    if (!col_is_list) {
      # Optimize rare non list-cols
      if (!is_null(col_ptype)) {
        col <- vec_cast(
          x = col,
          to = col_ptype,
          x_arg = col_name,
          call = error_call
        )
      }
      out_cols[[i]] <- vec_slice(col, out_loc)
      next
    }

    # Drop outer names because inner elements have varying size
    col <- unname(col)

    row_recycle <- col_sizes != sizes
    col[row_recycle] <- map2(
      col[row_recycle],
      sizes[row_recycle],
      vec_recycle,
      call = error_call
    )

    col <- list_unchop(
      x = col,
      ptype = col_ptype,
      error_arg = col_name,
      error_call = error_call
    )

    if (is_null(col)) {
      # This can happen when both of these are true:
      # - `col` was an empty list(), or a list of all `NULL`s.
      # - No ptype was specified for `col`, either by the user or by a list-of.
      if (out_size != 0L) {
        cli::cli_abort(
          "`NULL` column generated, but output size is not `0`.",
          .internal = TRUE
        )
      }

      col <- unspecified(0L)
    }

    out_cols[[i]] <- col
  }

  names(out_cols) <- x_names
  out_val <- new_data_frame(out_cols, n = out_size)

  out <- list(loc = out_loc, val = out_val)
  out <- new_data_frame(out, n = out_size)

  out
}
R/chop.R:173

unchop untypeabletyped

unbound variable (line 114)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
gradual mode: typed
((data: any, cols: any, ...: any, keep_empty: any?, ptype: any?, error_call: any?) -> any)<>
timing: 0.022 s
source
unchop <- function(
  data,
  cols,
  ...,
  keep_empty = FALSE,
  ptype = NULL,
  error_call = current_env()
) {
  check_dots_empty0(...)
  check_data_frame(data, call = error_call)
  check_required(cols, call = error_call)
  check_bool(keep_empty, call = error_call)

  sel <- tidyselect::eval_select(
    expr = enquo(cols),
    data = data,
    allow_rename = FALSE,
    error_call = error_call
  )

  size <- vec_size(data)
  names <- names(data)

  # Start from first principles to avoid issues in any subclass methods
  out <- new_data_frame(data, n = size)
  cols <- out[sel]

  # Remove unchopped columns to avoid slicing them needlessly later
  out[sel] <- NULL

  result <- df_unchop(
    x = cols,
    ptype = ptype,
    keep_empty = keep_empty,
    error_call = error_call
  )
  cols <- result$val
  loc <- result$loc

  out <- vec_slice(out, loc)

  # Add unchopped columns back on then preserve original ordering
  out <- tidyr_col_modify(out, cols)
  out <- out[names]

  reconstruct_tibble(data, out)
}
R/chop.R:108
R/fill.R

fill untypeabletyped

unbound variable (line 107)
unbound: check_dots_unnamed — a name the prelude does not declare
error detail
name: check_dots_unnamed
gradual mode: typed
((data: any, ...: any, .by: any?, .direction: any?) -> any)<>
timing: 0.027 s
source
fill <- function(
  data,
  ...,
  .by = NULL,
  .direction = c("down", "up", "downup", "updown")
) {
  check_dots_unnamed()
  UseMethod("fill")
}
R/fill.R:101

fill.data.frame skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
fill.data.frame <- function(
  data,
  ...,
  .by = NULL,
  .direction = c("down", "up", "downup", "updown")
) {
  vars <- names(tidyselect::eval_select(
    expr = expr(c(...)),
    data = data,
    allow_rename = FALSE
  ))

  .direction <- arg_match0(
    arg = .direction,
    values = c("down", "up", "downup", "updown"),
  )

  fn <- function(col) {
    vec_fill_missing(col, direction = .direction)
  }

  dplyr::mutate(
    data,
    dplyr::across(any_of(vars), .fns = fn),
    .by = {{ .by }}
  )
}
R/fill.R:112
R/id.R

id_var untypeabletyped

unbound variable (line 40)
unbound: is_null — a name the prelude does not declare
error detail
name: is_null
gradual mode: typed
((x: any with { n: any, any }, drop: dbl?) -> any)<>
timing: 0.171 s
source
id_var <- function(x, drop = FALSE) {
  if (!is_null(attr(x, "n", exact = TRUE)) && !drop) {
    return(x)
  }

  if (is.factor(x) && !drop) {
    x_na <- addNA(x, ifany = TRUE)
    id <- as.integer(x_na)
    n <- length(levels(x_na))
  } else if (length(x) == 0) {
    id <- integer()
    n <- 0L
  } else if (is_list(x)) {
    # Sorting lists isn't supported
    levels <- unique(x)
    id <- match(x, levels)
    n <- max(id)
  } else {
    levels <- sort(unique(x), na.last = TRUE)
    id <- match(x, levels)
    n <- max(id)
  }
  structure(id, n = n)
}
R/id.R:39

id untypeabletyped

unbound variable (line 9)
unbound: id_var — one of the package’s own names, itself untyped
error detail
name: id_var
gradual mode: typed
((.variables: { }<~@"[[", ...>, drop: any?) | (.variables: { any with { n: any, any } }<~@"[[", ...>, drop: dbl?) -> any)<>
timing: 0.176 s
source
id <- function(.variables, drop = FALSE) {
  if (length(.variables) == 0) {
    n <- nrow(.variables) %||% 0L
    return(structure(seq_len(n), n = n))
  }

  # Special case for single variable
  if (length(.variables) == 1) {
    return(id_var(.variables[[1]], drop = drop))
  }

  # Calculate individual ids
  ids <- rev(map(.variables, id_var, drop = drop))
  p <- length(ids)

  # Calculate dimensions
  ndistinct <- map_dbl(ids, attr, "n")
  n <- prod(ndistinct)
  if (n > 2^31) {
    # Too big for integers, have to use strings, which will be much slower :(

    char_id <- do.call("paste", c(ids, sep = "\r"))
    res <- match(char_id, unique(char_id))
  } else {
    combs <- c(1, cumprod(ndistinct[-p]))

    mat <- do.call("cbind", ids)
    res <- c((mat - 1L) %*% combs + 1L)
  }
  attr(res, "n") <- n

  if (drop) {
    id_var(res, drop = TRUE)
  } else {
    structure(as.integer(res), n = attr(res, "n"))
  }
}
R/id.R:1
R/spread.R

spread untypeabletyped

unbound variable (line 67)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((data: any, key: any, value: any, fill: any?, convert: any?, drop: any?, sep: any?) -> any)<>
timing: 0.068 s
source
spread <- function(
  data,
  key,
  value,
  fill = NA,
  convert = FALSE,
  drop = TRUE,
  sep = NULL
) {
  UseMethod("spread")
}
R/spread.R:58

as_tibble_matrix untypeable

untypeable projection (line 159)
error detail
argument: any
argument may be: new.env()
timing: 0.007 s
source
as_tibble_matrix <- function(x) {
  # getS3method() only available in R >= 3.3
  get("as_tibble.matrix", asNamespace("tibble"), mode = "function")(x)
}
R/spread.R:157

col_names typed empty return any: sep

((x: { }<~@"[[", ...>, sep: any?) -> empty)<>
timing: 0.127 s
source
col_names <- function(x, sep = NULL) {
  names <- as.character(x[[1]])

  if (is_null(sep)) {
    if (length(names) == 0) {
      # ifelse will return logical()
      character()
    } else {
      ifelse(are_na(names), "<NA>", names)
    }
  } else {
    paste(names(x)[[1]], names, sep = sep)
  }
}
R/spread.R:143

ulevels untypeabletyped

unbound variable (line 179)
unbound: addNA — a name the prelude does not declare
error detail
name: addNA
gradual mode: typed
((x: any) -> any)<>
timing: 0.035 s
source
ulevels <- function(x) {
  if (is.factor(x)) {
    orig_levs <- levels(x)
    x <- addNA(x, ifany = TRUE)
    levs <- levels(x)
    factor(levs, levels = orig_levs, ordered = is.ordered(x), exclude = NULL)
  } else if (is.list(x)) {
    unique(x)
  } else {
    sort(unique(x), na.last = TRUE)
  }
}
R/spread.R:176

split_labels untypeabletyped

unbound variable (line 167)
unbound: unique — a name the prelude does not declare
error detail
name: unique
gradual mode: typed
((df: any, id: any, drop: any?) -> any)<>
timing: 0.070 s
source
split_labels <- function(df, id, drop = TRUE) {
  if (length(df) == 0) {
    return(df)
  }

  if (drop) {
    representative <- match(sort(unique(id)), id)
    out <- df[representative, , drop = FALSE]
    rownames(out) <- NULL
    out
  } else {
    unique_values <- map(df, ulevels)
    rev(expand.grid(rev(unique_values), stringsAsFactors = FALSE))
  }
}
R/spread.R:161

spread.data.frame skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.017 s
source
spread.data.frame <- function(
  data,
  key,
  value,
  fill = NA,
  convert = FALSE,
  drop = TRUE,
  sep = NULL
) {
  key_var <- tidyselect::vars_pull(names(data), !!enquo(key))
  value_var <- tidyselect::vars_pull(names(data), !!enquo(value))

  col <- data[key_var]
  col_id <- id(col, drop = drop)
  col_labels <- split_labels(col, col_id, drop = drop)

  rows <- data[setdiff(names(data), c(key_var, value_var))]
  if (ncol(rows) == 0 && nrow(rows) > 0) {
    # Special case when there's only one row
    row_id <- structure(1L, n = 1L)
    row_labels <- as.data.frame(matrix(nrow = 1, ncol = 0))
  } else {
    row_id <- id(rows, drop = drop)
    row_labels <- split_labels(rows, row_id, drop = drop)
    rownames(row_labels) <- NULL
  }

  overall <- id(list(col_id, row_id), drop = FALSE)
  n <- attr(overall, "n")
  # Check that each output value occurs in unique location
  if (anyDuplicated(overall)) {
    groups <- split(seq_along(overall), overall)
    groups <- groups[map_int(groups, length) > 1]

    shared <- sum(map_int(groups, length))

    str <- map_chr(groups, function(x) paste0(x, collapse = ", "))
    cli::cli_abort(c(
      "Each row of output must be identified by a unique combination of keys.",
      i = "Keys are shared for {shared} rows",
      set_names(str, "*")
    ))
  }

  # Add in missing values, if necessary
  if (length(overall) < n) {
    overall <- match(seq_len(n), overall, nomatch = NA)
  } else {
    overall <- order(overall)
  }

  value <- data[[value_var]]
  ordered <- value[overall]
  if (!is.na(fill)) {
    ordered[is.na(ordered)] <- fill
  }

  if (convert && !is_character(ordered)) {
    ordered <- as.character(ordered)
  }
  dim(ordered) <- c(attr(row_id, "n"), attr(col_id, "n"))
  colnames(ordered) <- enc2utf8(col_names(col_labels, sep = sep))

  ordered <- as_tibble_matrix(ordered)

  if (convert) {
    ordered[] <- map(ordered, type.convert, as.is = TRUE)
  }

  out <- df_append(row_labels, ordered)
  reconstruct_tibble(data, out, c(key_var, value_var))
}
R/spread.R:70
R/expand.R

expand untypeabletyped

unbound variable (line 88)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((data: any, ...: any, .name_repair: any?) -> any)<>
timing: 0.006 s
source
expand <- function(data, ..., .name_repair = "check_unique") {
  UseMethod("expand")
}
R/expand.R:87

grid_dots untypeable

unbound variable (line 260)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
timing: 0.108 s
source
grid_dots <- function(..., `_data` = NULL, .error_call = caller_env()) {
  dots <- enquos(...)
  n_dots <- length(dots)

  names <- names(dots)
  needs_auto_name <- names == ""

  # Silently uniquely repair "auto-names" to avoid collisions
  # from truncated long names. Probably not a perfect system, but solves
  # most of the reported issues.
  auto_names <- names(exprs_auto_name(
    exprs = dots[needs_auto_name],
    repair_auto = "unique",
    repair_quiet = TRUE
  ))

  names[needs_auto_name] <- auto_names

  # Set up a mask for repeated `eval_tidy()` calls that support iterative
  # expressions
  env <- new_environment()
  mask <- new_data_mask(env)
  mask$.data <- as_data_pronoun(env)

  if (!is.null(`_data`)) {
    # Pre-load the data mask with `_data`
    cols <- tidyr_new_list(`_data`)
    col_names <- names(cols)

    for (i in seq_along(cols)) {
      col <- cols[[i]]
      col_name <- col_names[[i]]
      env[[col_name]] <- col
    }
  }

  out <- vector("list", length = n_dots)
  null <- vector("logical", length = n_dots)

  for (i in seq_len(n_dots)) {
    dot <- dots[[i]]
    dot <- eval_tidy(dot, data = mask)

    if (is.null(dot)) {
      null[[i]] <- TRUE
      next
    }

    arg <- paste0("..", i)
    vec_assert(dot, arg = arg, call = .error_call)

    out[[i]] <- dot

    is_unnamed_data_frame <- is.data.frame(dot) && needs_auto_name[[i]]

    if (is_unnamed_data_frame) {
      # Signal that unnamed data frame should be spliced by setting its name
      # to `""`. Then add its individual columns into the mask.
      names[[i]] <- ""

      dot_names <- names(dot)

      for (i in seq_along(dot)) {
        dot_col <- dot[[i]]
        dot_name <- dot_names[[i]]
        env[[dot_name]] <- dot_col
      }
    } else {
      # Install `dot` in the mask for iterative evaluations
      name <- names[[i]]
      env[[name]] <- dot
    }
  }

  if (any(null)) {
    out <- out[!null]
    names <- names[!null]
  }

  names(out) <- names

  out
}
R/expand.R:260

expand_grid untypeable

unbound variable (line 196)
unbound: grid_dots — one of the package’s own names, itself untyped
error detail
name: grid_dots
timing: 0.029 s
source
expand_grid <- function(..., .name_repair = "check_unique", .vary = "slowest") {
  out <- grid_dots(...)

  names <- names2(out)
  unnamed <- which(names == "")
  any_unnamed <- any(unnamed)

  if (any_unnamed) {
    # `vec_expand_grid()` requires all inputs to be named.
    # Most are auto named by `grid_dots()`, but unnamed data frames are not.
    # So we temporarily name unnamed data frames that eventually get spliced.
    names[unnamed] <- vec_paste0("...", unnamed)
    names(out) <- names
  }

  out <- vec_expand_grid(
    !!!out,
    .vary = .vary,
    .name_repair = "minimal",
    .error_call = current_env()
  )

  if (any_unnamed) {
    names[unnamed] <- ""
    names(out) <- names
  }

  size <- vec_size(out)

  # Flattens unnamed data frames after grid expansion
  out <- tidyr_new_list(out)
  out <- df_list(
    !!!out,
    .name_repair = .name_repair,
    .error_call = current_env()
  )
  out <- tibble::new_tibble(out, nrow = size)

  out
}
R/expand.R:195

fct_unique untypeabletyped

unbound variable (line 253)
unbound: anyNA — a name the prelude does not declare
error detail
name: anyNA
gradual mode: typed
((x: any) -> any)<>
timing: 0.052 s
source
fct_unique <- function(x) {
  levels <- levels(x)
  out <- levels

  if (!anyNA(levels) && anyNA(x)) {
    out <- c(out, NA_character_)
  }

  factor(out, levels = levels, exclude = NULL, ordered = is.ordered(x))
}
R/expand.R:249

sorted_unique untypeabletyped

unbound variable (line 240)
unbound: fct_unique — one of the package’s own names, itself untyped
error detail
name: fct_unique
gradual mode: typed
((x: any) -> any)<>
timing: 0.011 s
source
sorted_unique <- function(x) {
  if (is.factor(x)) {
    fct_unique(x)
  } else if (is_bare_list(x)) {
    vec_unique(x)
  } else {
    vec_sort(vec_unique(x))
  }
}
R/expand.R:238

expand.data.frame skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.007 s
source
expand.data.frame <- function(data, ..., .name_repair = "check_unique") {
  out <- grid_dots(..., `_data` = data)
  out <- map(out, sorted_unique)

  # Flattens unnamed data frames returned from `grid_dots()`
  out <- expand_grid(!!!out, .name_repair = .name_repair)

  reconstruct_tibble(data, out)
}
R/expand.R:92

expand.grouped_df skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.007 s
source
expand.grouped_df <- function(data, ..., .name_repair = "check_unique") {
  out <- dplyr::reframe(
    data,
    expand(
      data = dplyr::pick(everything()),
      ...,
      .name_repair = .name_repair
    )
  )

  drop <- dplyr::group_by_drop_default(data)

  dplyr::group_by(
    out,
    !!!dplyr::groups(data),
    .drop = drop
  )
}
R/expand.R:103

crossing untypeabletyped

unbound variable (line 127)
unbound: grid_dots — one of the package’s own names, itself untyped
error detail
name: grid_dots
gradual mode: typed
((...: any, .name_repair: any?) -> any)<>
timing: 0.011 s
source
crossing <- function(..., .name_repair = "check_unique") {
  out <- grid_dots(...)
  out <- map(out, sorted_unique)

  # Flattens unnamed data frames returned from `grid_dots()`
  expand_grid(!!!out, .name_repair = .name_repair)
}
R/expand.R:126

nesting untypeabletyped

unbound variable (line 137)
unbound: grid_dots — one of the package’s own names, itself untyped
error detail
name: grid_dots
gradual mode: typed
((...: any, .name_repair: any?) -> any)<>
timing: 0.018 s
source
nesting <- function(..., .name_repair = "check_unique") {
  out <- grid_dots(...)

  if (length(out) == 0L) {
    # This matches `crossing()`, `expand_grid()`, and `expand()`, which return
    # a 1 row / 0 col tibble. Computations involving the number of combinations
    # of an empty set should return 1.
    size <- 1L
  } else {
    size <- NULL
  }

  # Flattens unnamed data frames
  out <- data_frame(!!!out, .size = size, .name_repair = .name_repair)
  out <- tibble::new_tibble(out, nrow = vec_size(out))

  out <- sorted_unique(out)

  out
}
R/expand.R:136
R/replace_na.R

replace_na untypeabletyped

unbound variable (line 33)
unbound: check_dots_used — a name the prelude does not declare
error detail
name: check_dots_used
gradual mode: typed
((data: any, replace: any, ...: any) -> any)<>
timing: 0.005 s
source
replace_na <- function(data, replace, ...) {
  check_dots_used()
  UseMethod("replace_na")
}
R/replace_na.R:32

check_replacement untypeabletyped

unbound variable (line 95)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((x: any, var: any, call: any?) -> any)<>
timing: 0.010 s
source
check_replacement <- function(x, var, call = caller_env()) {
  n <- vec_size(x)

  if (n != 1) {
    cli::cli_abort(
      "Replacement for `{var}` must be length 1, not length {n}.",
      call = call
    )
  }
}
R/replace_na.R:95

replace_na.default untypeabletyped

unbound variable (line 39)
unbound: check_replacement — one of the package’s own names, itself untyped
error detail
name: check_replacement
gradual mode: typed
((data: any, replace: any?, ...: any) -> any)<>
timing: 0.021 s
source
replace_na.default <- function(data, replace = NA, ...) {
  check_replacement(replace, "data")

  if (vec_any_missing(data)) {
    missing <- vec_detect_missing(data)
    data <- vec_assign(
      data,
      missing,
      replace,
      x_arg = "data",
      value_arg = "replace"
    )
  }

  data
}
R/replace_na.R:38

replace_na.data.frame untypeable

unbound variable (line 57)
unbound: vec_is_list — a name the prelude does not declare
error detail
name: vec_is_list
timing: 0.041 s
source
replace_na.data.frame <- function(data, replace = list(), ...) {
  if (!vec_is_list(replace)) {
    cli::cli_abort(
      "{.arg replace} must be a list, not {.obj_type_friendly {replace}}."
    )
  }

  names <- intersect(names(replace), names(data))

  col_args <- as.character(glue("data${names}"))
  value_args <- as.character(glue("replace${names}"))

  for (i in seq_along(names)) {
    name <- names[[i]]

    col <- data[[name]]
    value <- replace[[name]]

    col_arg <- col_args[[i]]
    value_arg <- value_args[[i]]

    check_replacement(value, col_arg)

    if (vec_any_missing(col)) {
      missing <- vec_detect_missing(col)

      data[[name]] <- vec_assign(
        x = col,
        i = missing,
        value = value,
        x_arg = col_arg,
        value_arg = value_arg
      )
    }
  }

  data
}
R/replace_na.R:56
R/complete.R

complete untypeabletyped

unbound variable (line 65)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((data: any, ...: any, fill: any?, explicit: any?) -> any)<>
timing: 0.009 s
source
complete <- function(data, ..., fill = list(), explicit = TRUE) {
  UseMethod("complete")
}
R/complete.R:64

complete.data.frame untypeabletyped

unbound variable (line 70)
unbound: check_bool — one of the package’s own names, itself untyped
error detail
name: check_bool
gradual mode: typed
((data: any, ...: any, fill: any?, explicit: tt?) -> any)<>
timing: 0.031 s
source
complete.data.frame <- function(data, ..., fill = list(), explicit = TRUE) {
  check_bool(explicit)

  out <- expand(data, ...)
  names <- names(out)

  if (length(names) > 0L) {
    out <- dplyr::full_join(out, data, by = names, multiple = "all")
  } else {
    # Avoid joining the 1x0 result from `expand()` with `data`.
    # That causes issues when `data` has zero rows.
    out <- data
  }

  if (explicit) {
    out <- replace_na(out, replace = fill)
  } else {
    new <- !vec_in(out[names], data[names])
    slice <- vec_slice(out, new)
    slice <- replace_na(slice, replace = fill)
    out <- vec_assign(out, new, slice)
  }

  reconstruct_tibble(data, out)
}
R/complete.R:69

complete.grouped_df skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.007 s
source
complete.grouped_df <- function(data, ..., fill = list(), explicit = TRUE) {
  out <- dplyr::reframe(
    data,
    complete(
      data = dplyr::pick(everything()),
      ...,
      fill = fill,
      explicit = explicit
    )
  )

  drop <- dplyr::group_by_drop_default(data)

  dplyr::group_by(
    out,
    !!!dplyr::groups(data),
    .drop = drop
  )
}
R/complete.R:96
R/cpp11.R

melt_dataframe untypeabletyped

unbound variable (line 4)
unbound: _tidyr_melt_dataframe — a native symbol tyr could not bind
error detail
name: _tidyr_melt_dataframe
gradual mode: typed
((data: any, id_ind: any, measure_ind: any, variable_name: any, value_name: any, attrTemplate: any, factorsAsStrings: any, valueAsFactor: any, variableAsFactor: any) -> any)<>
timing: 0.079 s
source
melt_dataframe <- function(data, id_ind, measure_ind, variable_name, value_name, attrTemplate, factorsAsStrings, valueAsFactor, variableAsFactor) {
  .Call(`_tidyr_melt_dataframe`, data, id_ind, measure_ind, variable_name, value_name, attrTemplate, factorsAsStrings, valueAsFactor, variableAsFactor)
}
R/cpp11.R:3

simplifyPieces untypeabletyped

unbound variable (line 8)
unbound: _tidyr_simplifyPieces — a native symbol tyr could not bind
error detail
name: _tidyr_simplifyPieces
gradual mode: typed
((pieces: any, p: any, fillLeft: any) -> any)<>
timing: 0.006 s
source
simplifyPieces <- function(pieces, p, fillLeft) {
  .Call(`_tidyr_simplifyPieces`, pieces, p, fillLeft)
}
R/cpp11.R:7
R/data.R

<statement> typed

timing: 0.002 s
source
"who"
R/data.R:31

<statement> typed

timing: 0.003 s
source
"who2"
R/data.R:36

<statement> typed

timing: 0.003 s
source
"population"
R/data.R:46

<statement> typed

timing: 0.002 s
source
"table1"
R/data.R:64

<statement> typed

timing: 0.002 s
source
"table2"
R/data.R:68

<statement> typed

timing: 0.003 s
source
"table3"
R/data.R:72

<statement> typed

timing: 0.003 s
source
"table4a"
R/data.R:76

<statement> typed

timing: 0.002 s
source
"table4b"
R/data.R:80

<statement> typed

timing: 0.002 s
source
"table5"
R/data.R:84

<statement> typed

timing: 0.002 s
source
"smiths"
R/data.R:91

<statement> typed

timing: 0.003 s
source
"us_rent_income"
R/data.R:107

<statement> typed

timing: 0.002 s
source
"fish_encounters"
R/data.R:127

<statement> typed

timing: 0.002 s
source
"world_bank_pop"
R/data.R:144

<statement> typed

timing: 0.002 s
source
"relig_income"
R/data.R:157

<statement> typed

timing: 0.003 s
source
"construction"
R/data.R:172

<statement> typed

timing: 0.002 s
source
"billboard"
R/data.R:186

<statement> typed

timing: 0.002 s
source
"household"
R/data.R:201

<statement> typed

timing: 0.002 s
source
"cms_patient_experience"
R/data.R:253

<statement> typed

timing: 0.002 s
source
"cms_patient_care"
R/data.R:265
R/dep-extract.R

extract_numeric untypeabletyped

unbound variable (line 11)
unbound: message — a name the prelude does not declare
error detail
name: message
gradual mode: typed
(((x: vec | null) -> DBL<>)&((x: vec1) -> DBL1<>))<>
timing: 0.008 s
source
extract_numeric <- function(x) {
  message(
    "extract_numeric() is deprecated: please use readr::parse_number() instead"
  )
  as.numeric(gsub("[^0-9.-]+", "", as.character(x)))
}
R/dep-extract.R:10
R/drop-na.R

drop_na untypeabletyped

unbound variable (line 23)
unbound: check_dots_unnamed — a name the prelude does not declare
error detail
name: check_dots_unnamed
gradual mode: typed
((data: any, ...: any) -> any)<>
timing: 0.003 s
source
drop_na <- function(data, ...) {
  check_dots_unnamed()
  UseMethod("drop_na")
}
R/drop-na.R:22

drop_na.data.frame untypeabletyped

unbound variable (line 29)
unbound: enquos — a name the prelude does not declare
error detail
name: enquos
gradual mode: typed
((data: any, ...: any) -> any)<>
timing: 0.019 s
source
drop_na.data.frame <- function(data, ...) {
  dots <- enquos(...)

  if (is_empty(dots)) {
    # Use all columns if no `...` are supplied
    cols <- data
  } else {
    vars <- tidyselect::eval_select(
      expr(c(!!!dots)),
      data,
      allow_rename = FALSE
    )
    cols <- data[vars]
  }

  loc <- vec_detect_complete(cols)
  out <- vec_slice(data, loc)

  reconstruct_tibble(data, out)
}
R/drop-na.R:28
R/separate.R

separate untypeabletyped

unbound variable (line 86)
unbound: check_dots_used — a name the prelude does not declare
error detail
name: check_dots_used
gradual mode: typed
((data: any, col: any, into: any, sep: any?, remove: any?, convert: any?, extra: any?, fill: any?, ...: any) -> any)<>
timing: 0.131 s
source
separate <- function(
  data,
  col,
  into,
  sep = "[^[:alnum:]]+",
  remove = TRUE,
  convert = FALSE,
  extra = "warn",
  fill = "warn",
  ...
) {
  check_dots_used()
  UseMethod("separate")
}
R/separate.R:75

check_not_stringr_pattern untypeabletyped

unbound variable (line 233)
unbound: caller_arg — a name the prelude does not declare
error detail
name: caller_arg
gradual mode: typed
((x: any, arg: any?, call: any?) -> any)<>
timing: 0.014 s
source
check_not_stringr_pattern <- function(
  x,
  arg = caller_arg(x),
  call = caller_env()
) {
  if (inherits_any(x, c("pattern", "stringr_pattern"))) {
    cli::cli_abort(
      "{.arg {arg}} can't use modifiers from stringr.",
      call = call
    )
  }
}
R/separate.R:231

list_indices typed accepts outside

((x: vec<~@"[", ...>, max: dbl1?) -> CHR1<>)<>
timing: 0.274 s
fuzzing: 8 inside (8 ok) · 8 outside (4 rejected, 4 accepted)

Accepted outside the domain x: 4

parameterchangecallreturned
xwraplist_indices(list(c(42L, -2147483647L, 2L, NA_integer_, NA_integer_)))"c(42, -2147483647, 2, NA, NA)"<> with { }
xwraplist_indices("x" = list(as.raw(c(0, 0))))"as.raw(c(0x00, 0x00))"<> with { }
xwraplist_indices("x" = list(2))"2"<> with { }
xwraplist_indices(list(c(0.5, Inf, 42, NA_real_, 0)), 42L)"c(0.5, Inf, 42, NA, 0)"<> with { }
source
list_indices <- function(x, max = 20) {
  if (length(x) > max) {
    x <- c(x[seq_len(max)], "...")
  }

  paste(x, collapse = ", ")
}
R/separate.R:223

slice_match timeout

timing: 20.00 s
source
slice_match <- function(x, i) {
  structure(
    x[i],
    match.length = attr(x, "match.length")[i],
    index.type = attr(x, "index.type"),
    useBytes = attr(x, "useBytes")
  )
}
R/separate.R:214

str_split_n untypeabletyped

unbound variable (line 207)
unbound: gregexpr — a name the prelude does not declare
error detail
name: gregexpr
gradual mode: typed
((x: vec | null, pattern: any, n_max: vec?) -> any)<>
timing: 0.147 s
source
str_split_n <- function(x, pattern, n_max = -1) {
  if (is.factor(x)) {
    x <- as.character(x)
  }
  m <- gregexpr(pattern, x, perl = TRUE)
  if (n_max > 0) {
    m <- map(m, function(x) slice_match(x, seq_along(x) < n_max))
  }
  regmatches(x, m, invert = TRUE)
}
R/separate.R:203

str_split_fixed untypeable

unbound variable (line 176)
unbound: arg_match — a name the prelude does not declare
error detail
name: arg_match
timing: 0.130 s
source
str_split_fixed <- function(value, sep, n, extra = "warn", fill = "warn") {
  if (extra == "error") {
    warn(glue(
      "`extra = \"error\"` is deprecated. \\
       Please use `extra = \"warn\"` instead"
    ))
    extra <- "warn"
  }

  extra <- arg_match(extra, c("warn", "merge", "drop"))
  fill <- arg_match(fill, c("warn", "left", "right"))

  n_max <- if (extra == "merge") n else -1L
  pieces <- str_split_n(value, sep, n_max = n_max)

  simp <- simplifyPieces(pieces, n, fill == "left")

  n_big <- length(simp$too_big)
  if (extra == "warn" && n_big > 0) {
    idx <- list_indices(simp$too_big)
    warn(glue(
      "Expected {n} pieces. Additional pieces discarded in {n_big} rows [{idx}]."
    ))
  }

  n_sml <- length(simp$too_sml)
  if (fill == "warn" && n_sml > 0) {
    idx <- list_indices(simp$too_sml)
    warn(glue(
      "Expected {n} pieces. Missing pieces filled with `NA` in {n_sml} rows [{idx}]."
    ))
  }

  simp$strings
}
R/separate.R:167

strsep untypeabletimeout

unbound variable (line 157)
unbound: pmax — a name the prelude does not declare
error detail
name: pmax
gradual mode: timeout
timing: 7.64 s
source
strsep <- function(x, sep) {
  nchar <- nchar(x)
  pos <- map(sep, function(i) {
    if (i >= 0) {
      i
    } else {
      pmax(0, nchar + i)
    }
  })
  pos <- c(list(0), pos, list(nchar))

  map(1:(length(pos) - 1), function(i) {
    substr(x, pos[[i]] + 1, pos[[i + 1]])
  })
}
R/separate.R:151

str_separate untypeabletyped

unbound variable (line 126)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((x: any, into: any, sep: DBL | INT, convert: any?, extra: any?, fill: any?, error_call: any?) | (x: any, into: any, sep: ~(DBL | INT), convert: any?, extra: any?, fill: any?, error_call: any?) -> any)<>
timing: 0.108 s
source
str_separate <- function(
  x,
  into,
  sep,
  convert = FALSE,
  extra = "warn",
  fill = "warn",
  error_call = caller_env()
) {
  check_character(into, call = error_call)
  check_bool(convert, call = error_call)

  if (is.numeric(sep)) {
    out <- strsep(x, sep)
  } else if (is_string(sep)) {
    check_not_stringr_pattern(sep, call = error_call)
    out <- str_split_fixed(x, sep, length(into), extra = extra, fill = fill)
  } else {
    cli::cli_abort(
      "{.arg sep} must be a string or numeric vector, not {.obj_type_friendly {sep}}",
      call = error_call
    )
  }

  names(out) <- as_utf8_character(into)
  out <- out[!is.na(names(out))]
  if (convert) {
    out[] <- map(out, type.convert, as.is = TRUE)
  }
  as_tibble(out)
}
R/separate.R:119

separate.data.frame untypeabletyped

unbound variable (line 101)
unbound: check_required — a name the prelude does not declare
error detail
name: check_required
gradual mode: typed
((data: any, col: any, into: any, sep: any?, remove: any?, convert: any?, extra: any?, fill: any?, ...: any) -> any)<>
timing: 0.142 s
source
separate.data.frame <- function(
  data,
  col,
  into,
  sep = "[^[:alnum:]]+",
  remove = TRUE,
  convert = FALSE,
  extra = "warn",
  fill = "warn",
  ...
) {
  check_required(col)
  check_bool(remove)

  var <- tidyselect::vars_pull(names(data), !!enquo(col))
  value <- as.character(data[[var]])

  new_cols <- str_separate(
    value,
    into = into,
    sep = sep,
    convert = convert,
    extra = extra,
    fill = fill
  )
  out <- df_append(data, new_cols, var, remove = remove)
  reconstruct_tibble(data, out, if (remove) var else NULL)
}
R/separate.R:90
R/extract.R

extract untypeabletyped

unbound variable (line 55)
unbound: check_dots_used — a name the prelude does not declare
error detail
name: check_dots_used
gradual mode: typed
((data: any, col: any, into: any, regex: any?, remove: any?, convert: any?, ...: any) -> any)<>
timing: 0.059 s
source
extract <- function(
  data,
  col,
  into,
  regex = "([[:alnum:]]+)",
  remove = TRUE,
  convert = FALSE,
  ...
) {
  check_dots_used()
  UseMethod("extract")
}
R/extract.R:46

group_loc untypeabletyped

unbound variable (line 134)
unbound: as.vector — a name the prelude does not declare
error detail
name: as.vector
gradual mode: typed
((x: any with { match.length: any, capture.start: any, capture.length: any, any }) -> any)<>
timing: 0.012 s
source
group_loc <- function(x) {
  start <- cbind(as.vector(x), attr(x, "capture.start"))
  end <- start + cbind(attr(x, "match.length"), attr(x, "capture.length")) - 1L

  no_match <- start == -1L
  start[no_match] <- NA
  end[no_match] <- NA

  list(matches = ncol(start), start = start, end = end)
}
R/extract.R:133

str_match_first untypeable

unbound variable (line 124)
unbound: group_loc — one of the package’s own names, itself untyped
error detail
name: group_loc
timing: 0.101 s
source
str_match_first <- function(string, regex) {
  loc <- regexpr(regex, string, perl = TRUE)
  loc <- group_loc(loc)

  out <- map(
    seq_len(loc$matches),
    function(i) substr(string, loc$start[, i], loc$end[, i])
  )
  out[-1]
}
R/extract.R:122

str_extract untypeabletyped

unbound variable (line 83)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((x: any, into: any, regex: any, convert: any?, error_call: any?) -> any)<>
timing: 0.076 s
source
str_extract <- function(
  x,
  into,
  regex,
  convert = FALSE,
  error_call = caller_env()
) {
  check_string(regex, call = error_call)
  check_not_stringr_pattern(regex, call = error_call)
  check_character(into, call = error_call)
  check_bool(convert, call = error_call)

  out <- str_match_first(x, regex)
  if (length(out) != length(into)) {
    cli::cli_abort(
      "{.arg regex} should define {length(into)} groups; {length(out)} found.",
      call = error_call
    )
  }

  # Handle duplicated names
  if (anyDuplicated(into)) {
    pieces <- split(out, into)
    into <- names(pieces)
    out <- map(pieces, pmap_chr, vec_paste0)
  }

  into <- as_utf8_character(into)

  non_na_into <- !is.na(into)
  out <- out[non_na_into]
  names(out) <- into[non_na_into]

  out <- as_tibble(out)

  if (convert) {
    out[] <- map(out, type.convert, as.is = TRUE)
  }

  out
}
R/extract.R:78

extract.data.frame untypeabletyped

unbound variable (line 68)
unbound: check_required — a name the prelude does not declare
error detail
name: check_required
gradual mode: typed
((data: any, col: any, into: any, regex: any?, remove: any?, convert: any?, ...: any) -> any)<>
timing: 0.067 s
source
extract.data.frame <- function(
  data,
  col,
  into,
  regex = "([[:alnum:]]+)",
  remove = TRUE,
  convert = FALSE,
  ...
) {
  check_required(col)

  var <- tidyselect::vars_pull(names(data), !!enquo(col))
  value <- as.character(data[[var]])

  new_cols <- str_extract(value, into = into, regex = regex, convert = convert)
  out <- df_append(data, new_cols, var, remove = remove)
  reconstruct_tibble(data, out, if (remove) var else chr())
}
R/extract.R:59
R/gather.R

gather untypeabletyped

unbound variable (line 90)
unbound: check_dots_unnamed — a name the prelude does not declare
error detail
name: check_dots_unnamed
gradual mode: typed
((data: any, key: any?, value: any?, ...: any, na.rm: any?, convert: any?, factor_key: any?) -> any)<>
timing: 0.030 s
source
gather <- function(
  data,
  key = "key",
  value = "value",
  ...,
  na.rm = FALSE,
  convert = FALSE,
  factor_key = FALSE
) {
  check_dots_unnamed()
  UseMethod("gather")
}
R/gather.R:81

all_identical typed accepts outside

(((xs: <@"[[", ...>) | (xs: list<~@"[[", ...>) | (xs: vec<~@"[[", ...>) -> ff<> | tt<>) & ((xs: { }<~@"[[", ...>) -> tt<>))<>
timing: 0.379 s
fuzzing: 6 inside (6 ok) · 8 outside (4 rejected, 4 accepted)

Accepted outside the domain xs: 4

parameterchangecallreturned
xskind:envall_identical(new.env())tt<> with { }
xskind:funall_identical(function(...) NULL)tt<> with { }
xskind:langall_identical(quote(f(x)))ff<> with { }
xskind:nullall_identical("xs" = NULL)tt<> with { }
source
all_identical <- function(xs) {
  if (length(xs) <= 1) {
    return(TRUE)
  }
  for (i in seq(2, length(xs))) {
    if (!identical(xs[[1]], xs[[i]])) {
      return(FALSE)
    }
  }
  TRUE
}
R/gather.R:186

normalize_melt_arguments untypeabletyped

unbound variable (line 155)
unbound: map — a name the prelude does not declare
error detail
name: map
gradual mode: typed
∀'a,'b. (((data: v('b)<~@"[[", ...>, measure.ind: (CHR | DBL | INT | LGL | RAW)<~@"[", ...>) -> { factorsAsStrings: tt<>, attr_template: v1('b)<> | null }<>) & ((data: { }<~@"[[", ...>, measure.ind: CHR<~@"[", ...>) | (data: { }<~@"[[", ...>, measure.ind: dbl<~@"[", ...>) -> { factorsAsStrings: tt<>, attr_template: null }<>) & ((data: { 'a & <...> }<~@"[[", ...>, measure.ind: CHR<~@"[", ...>) | (data: { 'a & <...> }<~@"[[", ...>, measure.ind: dbl<~@"[", ...>) -> { factorsAsStrings: tt<>, attr_template: null | 'a }<>))<>
timing: 0.433 s
source
normalize_melt_arguments <- function(data, measure.ind) {
  measure.attributes <- map(measure.ind, function(i) {
    attributes(data[[i]])
  })

  ## Determine if all measure.attributes are equal
  measure.attrs.equal <- all_identical(measure.attributes)

  if (measure.attrs.equal) {
    attr_template <- data[[measure.ind[1]]]
  } else {
    warn(glue(
      "attributes are not identical across measure variables;
       they will be dropped"
    ))
    attr_template <- NULL
  }

  ## If we are going to be coercing any factors to strings, we don't want to
  ## copy the attributes
  any.factors <- any(map_lgl(measure.ind, function(i) is.factor(data[[i]])))

  if (any.factors) {
    attr_template <- NULL
  }

  list(
    attr_template = attr_template,
    factorsAsStrings = TRUE
  )
}
R/gather.R:154

gather.data.frame untypeabletyped

unbound variable (line 103)
unbound: ensym — a name the prelude does not declare
error detail
name: ensym
gradual mode: typed
((data: any, key: any?, value: any?, ...: any, na.rm: any?, convert: any?, factor_key: (vec | null)?) -> any)<>
timing: 0.105 s
source
gather.data.frame <- function(
  data,
  key = "key",
  value = "value",
  ...,
  na.rm = FALSE,
  convert = FALSE,
  factor_key = FALSE
) {
  key_var <- as_string(ensym(key))
  value_var <- as_string(ensym(value))

  quos <- quos(...)
  if (is_empty(quos)) {
    gather_vars <- setdiff(names(data), c(key_var, value_var))
  } else {
    gather_vars <- unname(tidyselect::vars_select(tbl_vars(data), !!!quos))
  }

  if (is_empty(gather_vars)) {
    return(data)
  }

  gather_idx <- match(gather_vars, names(data))
  id_idx <- setdiff(seq_along(data), gather_idx)

  dup_indx <- match(c(key_var, value_var), names(data))
  id_idx <- setdiff(id_idx, dup_indx)

  ## Get the attributes if common, NULL if not.
  args <- normalize_melt_arguments(data, gather_idx)
  valueAsFactor <- "factor" %in% class(args$attr_template)

  out <- melt_dataframe(
    data,
    id_idx - 1L,
    gather_idx - 1L,
    as.character(key_var),
    as.character(value_var),
    args$attr_template,
    args$factorsAsStrings,
    as.logical(valueAsFactor),
    as.logical(factor_key)
  )

  if (na.rm && anyNA(out)) {
    missing <- is.na(out[[value_var]])
    out <- out[!missing, ]
  }

  if (convert) {
    out[[key_var]] <- type.convert(as.character(out[[key_var]]), as.is = TRUE)
  }

  reconstruct_tibble(data, out, gather_vars)
}
R/gather.R:94
R/import-standalone-lazyeval.R

warn_underscored typed fuzz ok

(() -> null)<>
timing: 0.005 s
fuzzing: 1 inside (1 ok) · 1 outside (1 rejected)
source
warn_underscored <- function() {
  return(NULL)
  warn(paste(
    "The underscored versions are deprecated in favour of",
    "tidy evaluation idioms. Please see the documentation",
    "for `quo()` in rlang"
  ))
}
R/import-standalone-lazyeval.R:18

warn_text_se typed fuzz ok

(() -> null)<>
timing: 0.003 s
fuzzing: 1 inside (1 ok) · 1 outside (1 rejected)
source
warn_text_se <- function() {
  return(NULL)
  warn("Text parsing is deprecated, please supply an expression or formula")
}
R/import-standalone-lazyeval.R:26

compat_lazy untypeabletimeout

unbound variable (line 31)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: timeout
timing: 0.054 s
source
compat_lazy <- function(lazy, env = caller_env(), warn = TRUE) {
  if (warn) warn_underscored()

  if (missing(lazy)) {
    return(quo())
  }
  if (is_quosure(lazy)) {
    return(lazy)
  }
  if (is_formula(lazy)) {
    return(as_quosure(lazy, env))
  }

  out <- switch(typeof(lazy),
    symbol = ,
    language = new_quosure(lazy, env),
    character = {
      if (warn) warn_text_se()
      parse_quo(lazy[[1]], env)
    },
    logical = ,
    integer = ,
    double = {
      if (length(lazy) > 1) {
        warn("Truncating vector to length 1")
        lazy <- lazy[[1]]
      }
      new_quosure(lazy, env)
    },
    list =
      if (inherits(lazy, "lazy")) {
        lazy = new_quosure(lazy$expr, lazy$env)
      }
  )

  if (is_null(out)) {
    abort(sprintf("Can't convert a %s to a quosure", typeof(lazy)))
  } else {
    out
  }
}
R/import-standalone-lazyeval.R:31

compat_lazy_dots untypeable

unbound variable (line 86)
unbound: compat_lazy — one of the package’s own names, itself untyped
error detail
name: compat_lazy
timing: 1.43 s
source
compat_lazy_dots <- function(dots, env, ..., .named = FALSE) {
  if (missing(dots)) {
    dots <- list()
  }
  if (inherits(dots, c("lazy", "formula"))) {
    dots <- list(dots)
  } else {
    dots <- unclass(dots)
  }
  dots <- c(dots, list(...))

  warn <- TRUE
  for (i in seq_along(dots)) {
    dots[[i]] <- compat_lazy(dots[[i]], env, warn)
    warn <- FALSE
  }

  named <- have_name(dots)
  if (.named && any(!named)) {
    nms <- vapply(dots[!named], function(x) expr_text(get_expr(x)), character(1))
    names(dots)[!named] <- nms
  }

  names(dots) <- names2(dots)
  dots
}
R/import-standalone-lazyeval.R:73

compat_as_lazy skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
compat_as_lazy <- function(quo) {
  structure(class = "lazy", list(
    expr = get_expr(quo),
    env = get_env(quo)
  ))
}
R/import-standalone-lazyeval.R:100

compat_as_lazy_dots skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
compat_as_lazy_dots <- function(...) {
  structure(class = "lazy_dots", lapply(quos(...), compat_as_lazy))
}
R/import-standalone-lazyeval.R:106
R/separate-rows.R

separate_rows untypeabletyped

unbound variable (line 32)
unbound: check_dots_unnamed — a name the prelude does not declare
error detail
name: check_dots_unnamed
gradual mode: typed
((data: any, ...: any, sep: any?, convert: any?) -> any)<>
timing: 0.008 s
source
separate_rows <- function(data, ..., sep = "[^[:alnum:].]+", convert = FALSE) {
  check_dots_unnamed()
  UseMethod("separate_rows")
}
R/separate-rows.R:31

separate_rows.data.frame untypeabletyped

unbound variable (line 43)
unbound: check_string — one of the package’s own names, itself untyped
error detail
name: check_string
gradual mode: typed
((data: any, ...: list | null, sep: any?, convert: any?) | (data: any, ...: vec | null, sep: any?, convert: any?) -> any)<>
timing: 0.019 s
source
separate_rows.data.frame <- function(
  data,
  ...,
  sep = "[^[:alnum:].]+",
  convert = FALSE
) {
  check_string(sep)
  check_bool(convert)

  vars <- tidyselect::eval_select(expr(c(...)), data, allow_rename = FALSE)
  vars <- names(vars)

  out <- purrr::modify_at(data, vars, str_split_n, pattern = sep)
  out <- unchop(as_tibble(out), any_of(vars), error_call = current_env())
  if (convert) {
    out[vars] <- map(out[vars], type.convert, as.is = TRUE)
  }

  reconstruct_tibble(data, out, vars)
}
R/separate-rows.R:37
R/unite.R

unite untypeabletyped

unbound variable (line 35)
unbound: check_dots_unnamed — a name the prelude does not declare
error detail
name: check_dots_unnamed
gradual mode: typed
((data: any, col: any, ...: any, sep: any?, remove: any?, na.rm: any?) -> any)<>
timing: 0.017 s
source
unite <- function(data, col, ..., sep = "_", remove = TRUE, na.rm = FALSE) {
  check_dots_unnamed()
  UseMethod("unite")
}
R/unite.R:34

unite.data.frame untypeable

unbound variable (line 47)
unbound: check_required — a name the prelude does not declare
error detail
name: check_required
timing: 0.133 s
source
unite.data.frame <- function(
  data,
  col,
  ...,
  sep = "_",
  remove = TRUE,
  na.rm = FALSE
) {
  check_required(col)
  check_string(sep)
  check_bool(remove)
  check_bool(na.rm)

  col <- as_string(ensym(col))
  col <- enc2utf8(col)

  if (dots_n(...) == 0) {
    selection <- set_names(seq_along(data), names(data))
  } else {
    selection <- tidyselect::eval_select(
      expr(c(...)),
      data,
      allow_rename = FALSE
    )
  }

  empty_selection <- length(selection) == 0L

  out <- data
  if (remove) {
    out <- out[setdiff(names(out), names(selection))]
  }

  if (empty_selection) {
    # Use initial value implied by the reduction algorithm (#1570)
    united <- vec_rep("", times = vec_size(data))
  } else if (identical(na.rm, TRUE)) {
    cols <- unname(map(data[selection], as.character))
    rows <- transpose(cols)
    united <- map_chr(rows, function(x) paste0(x[!is.na(x)], collapse = sep))
  } else {
    cols <- unname(as.list(data[selection]))
    united <- exec(paste, !!!cols, sep = sep)
  }

  united <- list(united)
  names(united) <- col

  if (empty_selection) {
    after <- length(data)
  } else {
    loc_first_selection <- which(names(data) %in% names(selection))[[1L]]
    after <- loc_first_selection - 1L
  }

  out <- df_append(out, united, after = after)

  reconstruct_tibble(
    input = data,
    output = out,
    ungrouped_vars = if (remove) names(selection)
  )
}
R/unite.R:39
R/dep-lazyeval.R

<statement> typed

timing: 0.000 s
source
NULL
R/dep-lazyeval.R:26

complete_ untypeabletyped

unbound variable (line 32)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, cols: any, fill: any?, ...: any) -> any)<>
timing: 0.016 s
source
complete_ <- function(data, cols, fill = list(), ...) {
  lifecycle::deprecate_warn("1.0.0", "complete_()", "complete()", always = TRUE)
  UseMethod("complete_")
}
R/dep-lazyeval.R:31

complete_.data.frame untypeabletyped

unbound variable (line 37)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((data: any, cols: any, fill: any?, ...: any) -> any)<>
timing: 0.023 s
source
complete_.data.frame <- function(data, cols, fill = list(), ...) {
  cols <- compat_lazy_dots(cols, caller_env())
  complete(data, !!!cols, fill = fill)
}
R/dep-lazyeval.R:36

drop_na_ untypeabletyped

unbound variable (line 44)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, vars: any) -> any)<>
timing: 0.005 s
source
drop_na_ <- function(data, vars) {
  lifecycle::deprecate_warn("1.0.0", "drop_na_()", "drop_na()", always = TRUE)
  UseMethod("drop_na_")
}
R/dep-lazyeval.R:43

drop_na_.data.frame untypeabletyped

unbound variable (line 49)
unbound: drop_na — one of the package’s own names, itself untyped
error detail
name: drop_na
gradual mode: typed
((data: any, vars: dbl) -> any)<>
timing: 0.124 s
source
drop_na_.data.frame <- function(data, vars) {
  drop_na(data, !!!vars)
}
R/dep-lazyeval.R:48

expand_ untypeabletyped

unbound variable (line 55)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, dots: any, ...: any) -> any)<>
timing: 0.007 s
source
expand_ <- function(data, dots, ...) {
  lifecycle::deprecate_warn("1.0.0", "expand_()", "expand()", always = TRUE)
  UseMethod("expand_")
}
R/dep-lazyeval.R:54

expand_.data.frame untypeabletyped

unbound variable (line 60)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((data: any, dots: any, ...: any) -> any)<>
timing: 0.014 s
source
expand_.data.frame <- function(data, dots, ...) {
  dots <- compat_lazy_dots(dots, caller_env())
  expand(data, !!!dots)
}
R/dep-lazyeval.R:59

crossing_ untypeabletyped

unbound variable (line 67)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((x: any) -> any)<>
timing: 0.011 s
source
crossing_ <- function(x) {
  lifecycle::deprecate_warn("1.0.0", "crossing_()", "crossing()", always = TRUE)
  x <- compat_lazy_dots(x, caller_env())
  crossing(!!!x)
}
R/dep-lazyeval.R:66

nesting_ untypeabletyped

unbound variable (line 74)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((x: any) -> any)<>
timing: 0.011 s
source
nesting_ <- function(x) {
  lifecycle::deprecate_warn("1.2.0", "nesting_()", "nesting()", always = TRUE)
  x <- compat_lazy_dots(x, caller_env())
  nesting(!!!x)
}
R/dep-lazyeval.R:73

extract_ untypeabletyped

unbound variable (line 91)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, col: any, into: any, regex: any?, remove: any?, convert: any?, ...: any) -> any)<>
timing: 0.055 s
source
extract_ <- function(
  data,
  col,
  into,
  regex = "([[:alnum:]]+)",
  remove = TRUE,
  convert = FALSE,
  ...
) {
  lifecycle::deprecate_warn("1.0.0", "extract_()", "extract()", always = TRUE)
  UseMethod("extract_")
}
R/dep-lazyeval.R:82

extract_.data.frame untypeabletyped

unbound variable (line 104)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((data: any, col: any, into: any, regex: any?, remove: any?, convert: any?, ...: any) -> any)<>
timing: 0.061 s
source
extract_.data.frame <- function(
  data,
  col,
  into,
  regex = "([[:alnum:]]+)",
  remove = TRUE,
  convert = FALSE,
  ...
) {
  col <- compat_lazy(col, caller_env())
  extract(
    data,
    col = !!col,
    into = into,
    regex = regex,
    remove = remove,
    convert = convert,
    ...
  )
}
R/dep-lazyeval.R:95

fill_ untypeabletyped

unbound variable (line 121)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, fill_cols: any, .direction: any?) -> any)<>
timing: 0.026 s
source
fill_ <- function(data, fill_cols, .direction = c("down", "up")) {
  lifecycle::deprecate_warn("1.2.0", "fill_()", "fill()", always = TRUE)
  UseMethod("fill_")
}
R/dep-lazyeval.R:120

fill_.data.frame untypeabletyped

unbound variable (line 130)
unbound: syms — a name the prelude does not declare
error detail
name: syms
gradual mode: typed
((data: any, fill_cols: any, .direction: any?) -> any)<>
timing: 0.038 s
source
fill_.data.frame <- function(
  data,
  fill_cols,
  .direction = c("down", "up", "downup", "updown")
) {
  vars <- syms(fill_cols)
  fill(data, !!!vars, .direction = .direction)
}
R/dep-lazyeval.R:125

gather_ untypeabletyped

unbound variable (line 151)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, key_col: any, value_col: any, gather_cols: any, na.rm: any?, convert: any?, factor_key: any?) -> any)<>
timing: 0.067 s
source
gather_ <- function(
  data,
  key_col,
  value_col,
  gather_cols,
  na.rm = FALSE,
  convert = FALSE,
  factor_key = FALSE
) {
  lifecycle::deprecate_warn("1.2.0", "gather_()", "gather()", always = TRUE)
  UseMethod("gather_")
}
R/dep-lazyeval.R:142

gather_.data.frame skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
gather_.data.frame <- function(
  data,
  key_col,
  value_col,
  gather_cols,
  na.rm = FALSE,
  convert = FALSE,
  factor_key = FALSE
) {
  key_col <- sym(key_col)
  value_col <- sym(value_col)
  gather_cols <- syms(gather_cols)

  gather(
    data,
    key = !!key_col,
    value = !!value_col,
    !!!gather_cols,
    na.rm = na.rm,
    convert = convert,
    factor_key = factor_key
  )
}
R/dep-lazyeval.R:155

nest_ untypeabletyped

unbound variable (line 184)
unbound: lifecycle::deprecate_stop — a name the prelude does not declare
error detail
name: lifecycle::deprecate_stop
gradual mode: typed
((...: any) -> any)<>
timing: 0.003 s
source
nest_ <- function(...) {
  lifecycle::deprecate_stop("1.0.0", "nest_()", "nest()", always = TRUE)
}
R/dep-lazyeval.R:183

separate_rows_ untypeabletyped

unbound variable (line 196)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, cols: any, sep: any?, convert: any?) -> any)<>
timing: 0.019 s
source
separate_rows_ <- function(
  data,
  cols,
  sep = "[^[:alnum:].]+",
  convert = FALSE
) {
  lifecycle::deprecate_warn("1.2.0", "separate_rows_()", "separate_rows()")
  UseMethod("separate_rows_")
}
R/dep-lazyeval.R:190

separate_rows_.data.frame untypeabletyped

unbound variable (line 206)
unbound: syms — a name the prelude does not declare
error detail
name: syms
gradual mode: typed
((data: any, cols: any, sep: any?, convert: any?) -> any)<>
timing: 0.027 s
source
separate_rows_.data.frame <- function(
  data,
  cols,
  sep = "[^[:alnum:].]+",
  convert = FALSE
) {
  cols <- syms(cols)
  separate_rows(data, !!!cols, sep = sep, convert = convert)
}
R/dep-lazyeval.R:200

separate_ untypeabletyped

unbound variable (line 224)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, col: any, into: any, sep: any?, remove: any?, convert: any?, extra: any?, fill: any?, ...: any) -> any)<>
timing: 0.126 s
source
separate_ <- function(
  data,
  col,
  into,
  sep = "[^[:alnum:]]+",
  remove = TRUE,
  convert = FALSE,
  extra = "warn",
  fill = "warn",
  ...
) {
  lifecycle::deprecate_warn("1.2.0", "separate_()", "separate()", always = TRUE)
  UseMethod("separate_")
}
R/dep-lazyeval.R:213

separate_.data.frame untypeabletyped

unbound variable (line 239)
unbound: sym — a name the prelude does not declare
error detail
name: sym
gradual mode: typed
((data: any, col: any, into: any, sep: any?, remove: any?, convert: any?, extra: any?, fill: any?, ...: any) -> any)<>
timing: 0.145 s
source
separate_.data.frame <- function(
  data,
  col,
  into,
  sep = "[^[:alnum:]]+",
  remove = TRUE,
  convert = FALSE,
  extra = "warn",
  fill = "warn",
  ...
) {
  col <- sym(col)
  separate(
    data,
    col = !!col,
    into = into,
    sep = sep,
    remove = remove,
    convert = convert,
    extra = extra,
    fill = fill,
    ...
  )
}
R/dep-lazyeval.R:228

spread_ untypeabletyped

unbound variable (line 265)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, key_col: any, value_col: any, fill: any?, convert: any?, drop: any?, sep: any?) -> any)<>
timing: 0.078 s
source
spread_ <- function(
  data,
  key_col,
  value_col,
  fill = NA,
  convert = FALSE,
  drop = TRUE,
  sep = NULL
) {
  lifecycle::deprecate_warn("1.2.0", "spread_()", "spread()", always = TRUE)
  UseMethod("spread_")
}
R/dep-lazyeval.R:256

spread_.data.frame untypeabletyped

unbound variable (line 278)
unbound: sym — a name the prelude does not declare
error detail
name: sym
gradual mode: typed
((data: any, key_col: any, value_col: any, fill: any?, convert: any?, drop: any?, sep: any?) -> any)<>
timing: 0.088 s
source
spread_.data.frame <- function(
  data,
  key_col,
  value_col,
  fill = NA,
  convert = FALSE,
  drop = TRUE,
  sep = NULL
) {
  key_col <- sym(key_col)
  value_col <- sym(value_col)

  spread(
    data,
    key = !!key_col,
    value = !!value_col,
    fill = fill,
    convert = convert,
    drop = drop,
    sep = sep
  )
}
R/dep-lazyeval.R:269

unite_ untypeabletyped

unbound variable (line 297)
unbound: lifecycle::deprecate_warn — a name the prelude does not declare
error detail
name: lifecycle::deprecate_warn
gradual mode: typed
((data: any, col: any, from: any, sep: any?, remove: any?) -> any)<>
timing: 0.074 s
source
unite_ <- function(data, col, from, sep = "_", remove = TRUE) {
  lifecycle::deprecate_warn("1.2.0", "unite_()", "unite()", always = TRUE)
  UseMethod("unite_")
}
R/dep-lazyeval.R:296

unite_.data.frame untypeabletyped

unbound variable (line 302)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((data: any, col: any, from: any, sep: any?, remove: any?) -> any)<>
timing: 0.042 s
source
unite_.data.frame <- function(data, col, from, sep = "_", remove = TRUE) {
  col <- quo_get_expr(compat_lazy(col, caller_env()))
  from <- syms(from)
  unite(data, !!col, !!!from, sep = sep, remove = remove)
}
R/dep-lazyeval.R:301

unnest_ untypeabletyped

unbound variable (line 311)
unbound: lifecycle::deprecate_stop — a name the prelude does not declare
error detail
name: lifecycle::deprecate_stop
gradual mode: typed
((...: any) -> any)<>
timing: 0.002 s
source
unnest_ <- function(...) {
  lifecycle::deprecate_stop("1.0.0", "unnest_()", "unnest()")
}
R/dep-lazyeval.R:310
R/doc-params.R

<statement> typed

timing: 0.000 s
source
NULL
R/doc-params.R:82

<statement> typed

timing: 0.000 s
source
NULL
R/doc-params.R:125
R/unnest-helper.R

col_simplify untypeable

unbound variable (line 50)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
timing: 0.196 s
source
col_simplify <- function(
  x,
  ...,
  ptype = NULL,
  transform = NULL,
  simplify = TRUE,
  error_call = caller_env()
) {
  check_dots_empty()

  if (!is.null(transform)) {
    transform <- as_function(transform)
  }

  if (!vec_is_list(x)) {
    if (!is.null(transform)) {
      x <- transform(x)
    }
    if (!is.null(ptype)) {
      x <- vec_cast(x, ptype, call = error_call)
    }
    return(x)
  }

  if (!is.null(transform)) {
    x <- tidyr_new_list(x)
    x <- map(x, transform)
    # Can't convert result to list_of, as we can't be certain of element types
  }
  if (!is.null(ptype)) {
    x <- tidyr_new_list(x)
    x <- vec_cast_common(!!!x, .to = ptype, .call = error_call)
    x <- new_list_of(x, ptype = ptype)
  }

  if (!simplify) {
    return(x)
  }

  # Don't simplify lists of lists, because that typically indicates that
  # there might be multiple values.
  if (is_list_of(x)) {
    has_list_of_list <- vec_is_list(list_of_ptype(x))
  } else {
    has_list_of_list <- any(map_lgl(x, vec_is_list))
  }
  if (has_list_of_list) {
    return(x)
  }

  # Don't try and simplify non-vectors. list-of types always contain vectors.
  if (is_list_of(x)) {
    has_non_vector <- FALSE
  } else {
    has_non_vector <- !list_all_vectors2(x)
  }
  if (has_non_vector) {
    return(x)
  }

  out <- tidyr_new_list(x)
  ptype <- list_of_ptype(x)
  sizes <- list_sizes(out)

  # Ensure empty elements are filled in with their correct size 1 equivalent
  info <- list_replace_null(out, sizes, ptype = ptype)
  out <- info$x
  sizes <- info$sizes

  info <- list_replace_empty_typed(out, sizes, ptype = ptype)
  out <- info$x
  sizes <- info$sizes

  # Don't try to simplify if there are any size >1 left at this point
  has_non_scalar <- any(sizes != 1L)
  if (has_non_scalar) {
    return(x)
  }

  # Assume that if combining fails, then we want to return the object
  # after the `ptype` and `transform` have been applied, but before the
  # empty element filling and list attribute stripping was applied
  tryCatch(
    list_unchop(out, ptype = ptype),
    vctrs_error_incompatible_type = function(e) x
  )
}
R/unnest-helper.R:44

df_simplify untypeabletyped

unbound variable (line 9)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((x: <@"[[", ...>, ...: any, ptype: any?, transform: any?, simplify: any?, error_call: absent) | (x: list<~@"[[", ...>, ...: any, ptype: any?, transform: any?, simplify: any?, error_call: absent) | (x: vec<~@"[[", ...>, ...: any, ptype: any?, transform: any?, simplify: any?, error_call: absent) -> any)<>
timing: 0.027 s
source
df_simplify <- function(
  x,
  ...,
  ptype = NULL,
  transform = NULL,
  simplify = TRUE,
  error_call = caller_env()
) {
  check_dots_empty()

  ptype <- check_list_of_ptypes(ptype, names(x), call = error_call)
  transform <- check_list_of_functions(transform, names(x), call = error_call)
  simplify <- check_list_of_bool(simplify, names(x), call = error_call)

  x_n <- length(x)
  x_size <- vec_size(x)
  x_names <- names(x)

  out <- vector("list", length = x_n)
  names(out) <- x_names

  for (i in seq_len(x_n)) {
    col <- x[[i]]
    col_name <- x_names[[i]]

    col_ptype <- ptype[[col_name]]
    col_transform <- transform[[col_name]]
    col_simplify <- simplify[[col_name]] %||% TRUE

    out[[i]] <- col_simplify(
      x = col,
      ptype = col_ptype,
      transform = col_transform,
      simplify = col_simplify,
      error_call = error_call
    )
  }

  new_data_frame(out, n = x_size)
}
R/unnest-helper.R:3
R/hoist.R

check_pluckers untypeabletyped

unbound variable (line 141)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((...: any, .call: any?) -> any)<>
timing: 0.022 s
source
check_pluckers <- function(..., .call = caller_env()) {
  pluckers <- list2(...)

  is_string <- map_lgl(pluckers, ~ is.character(.x) && length(.x) == 1)
  auto_name <- names2(pluckers) == "" & is_string

  if (any(auto_name)) {
    names(pluckers)[auto_name] <- unlist(pluckers[auto_name])
  }

  check_unique_names(pluckers, arg = "...", call = .call)

  # Standardize all pluckers to lists for splicing into `pluck()`
  # and for easier handling in `strike()`
  is_not_list <- !map_lgl(pluckers, vec_is_list)
  pluckers[is_not_list] <- map(pluckers[is_not_list], vec_chop)

  pluckers
}
R/hoist.R:141

strike untypeabletimeout

unbound variable (line 162)
unbound: vec_is_list — a name the prelude does not declare
error detail
name: vec_is_list
gradual mode: timeout
timing: 3.38 s
source
strike <- function(x, indices) {
  if (!vec_is_list(indices)) {
    cli::cli_abort("{.arg indices} must be a list.", .internal = TRUE)
  }

  n_indices <- vec_size(indices)

  if (n_indices == 0L) {
    # Edge case corresponding to an empty plucker
    return(x)
  }

  index <- indices[[1L]]
  indices <- indices[-1L]

  size <- vec_size(x)

  is_valid_index <-
    (is.numeric(index) && (index <= size)) ||
    (is.character(index) && has_name(x, index))

  if (!is_valid_index) {
    # Nothing to do if the `pluck()` missed entirely
    return(x)
  }

  index <- vec_as_location(index, n = size, names = names(x))

  if (n_indices == 1L) {
    # At base index, remove it
    x <- x[-index]
  } else {
    # Not at base index yet, continue recursion
    x[[index]] <- strike(x[[index]], indices)
  }

  x
}
R/hoist.R:161

hoist untypeable

unbound variable (line 86)
unbound: check_data_frame — one of the package’s own names, itself untyped
error detail
name: check_data_frame
timing: 0.050 s
source
hoist <- function(
  .data,
  .col,
  ...,
  .remove = TRUE,
  .simplify = TRUE,
  .ptype = NULL,
  .transform = NULL
) {
  check_data_frame(.data)
  check_required(.col)
  pluckers <- check_pluckers(...)
  check_bool(.remove)

  .col <- tidyselect::vars_pull(names(.data), {{ .col }})
  x <- .data[[.col]]
  vec_check_list(x, arg = ".data[[.col]]")

  # These are also checked in df_simplify(), but we check here to generate
  # errors with argument names
  check_list_of_ptypes(.ptype, names(x))
  check_list_of_bool(.simplify, names(x))
  check_list_of_functions(.transform, names(x))

  # In R <4.1, `::` is quite slow and this is a tight loop, so eliminating
  # the lookup has a large performance impact:
  # https://github.com/tidyverse/tidyr/issues/1001
  pluck <- purrr::pluck
  cols <- map(pluckers, function(idx) {
    map(x, ~ pluck(.x, !!!idx))
  })
  cols <- new_data_frame(cols, n = vec_size(.data))

  cols <- df_simplify(
    cols,
    ptype = .ptype,
    transform = .transform,
    simplify = .simplify
  )

  # Place new columns before old column
  out <- df_append(.data, cols, after = match(.col, names(.data)) - 1L)

  if (.remove) {
    x <- map(x, function(x) {
      # rev() is sneaky hack assuming that most people will remove in
      # numeric order, so this should avoid most order problems. A full
      # resolution will be considerably more work.
      for (plucker in rev(pluckers)) {
        x <- strike(x, plucker)
      }
      x
    })

    if (every(x, is_empty)) {
      x <- NULL
    }

    out[[.col]] <- x
  }

  reconstruct_tibble(.data, out)
}
R/hoist.R:77
R/nest-legacy.R

nest_legacy untypeabletyped

unbound variable (line 72)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((data: any, ...: any, .key: any?) -> any)<>
timing: 0.006 s
source
nest_legacy <- function(data, ..., .key = "data") {
  UseMethod("nest_legacy")
}
R/nest-legacy.R:71

nest_legacy.tbl_df untypeable

unbound variable (line 78)
unbound: ensym — a name the prelude does not declare
error detail
name: ensym
timing: 0.058 s
source
nest_legacy.tbl_df <- function(data, ..., .key = "data") {
  key_var <- as_string(ensym(.key))
  nest_vars <- unname(tidyselect::vars_select(names(data), ...))

  if (is_empty(nest_vars)) {
    nest_vars <- names(data)
  }

  if (dplyr::is_grouped_df(data)) {
    group_vars <- dplyr::group_vars(data)
  } else {
    group_vars <- setdiff(names(data), nest_vars)
  }
  nest_vars <- setdiff(nest_vars, group_vars)

  data <- dplyr::ungroup(data)
  if (is_empty(group_vars)) {
    return(tibble(!!key_var := list(data)))
  }

  out <- dplyr::select(data, !!!syms(group_vars))

  grouped_data <- dplyr::group_by(data, !!!syms(group_vars), .drop = TRUE)
  idx <- dplyr::group_indices(grouped_data)

  representatives <- which(!duplicated(idx))

  out <- dplyr::slice(out, representatives)
  out[[key_var]] <- unname(split(data[nest_vars], idx))[unique(idx)]
  out
}
R/nest-legacy.R:77

nest_legacy.data.frame skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
nest_legacy.data.frame <- function(data, ..., .key = "data") {
  .key <- enquo(.key)

  # Don't transform subclasses
  if (identical(class(data), "data.frame")) {
    data <- tibble::as_tibble(data)
  }

  nest_legacy.tbl_df(data, ..., .key = !!.key)
}
R/nest-legacy.R:110

unnest_legacy untypeabletyped

unbound variable (line 131)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((data: any, ...: any, .drop: any?, .id: any?, .sep: any?, .preserve: any?) -> any)<>
timing: 0.014 s
source
unnest_legacy <- function(
  data,
  ...,
  .drop = NA,
  .id = NULL,
  .sep = NULL,
  .preserve = NULL
) {
  UseMethod("unnest_legacy")
}
R/nest-legacy.R:123

id_col untypeabletyped

unbound variable (line 255)
unbound: is_list — a name the prelude does not declare
error detail
name: is_list
gradual mode: typed
((x: any) -> any)<>
timing: 0.012 s
source
id_col <- function(x) {
  stopifnot(is_list(x))

  ids <- if (is_null(names(x))) seq_along(x) else names(x)
  lengths <- map_int(x, length)

  ids[rep(seq_along(ids), lengths)]
}
R/nest-legacy.R:254

enframe untypeabletyped

unbound variable (line 238)
unbound: is_list — a name the prelude does not declare
error detail
name: is_list
gradual mode: typed
((x: any, col_name: any, .id: any?) -> any)<>
timing: 0.046 s
source
enframe <- function(x, col_name, .id = NULL) {
  if (!is_list(x)) {
    x <- list(x)
  }

  col <- unname(x)
  col <- list_unchop(col)

  out <- set_names(list(col), col_name)
  out <- as_tibble(out)

  if (!is_null(.id)) {
    out[[.id]] <- id_col(x)
  }

  out
}
R/nest-legacy.R:237

list_col_type untypeabletyped

unbound variable (line 223)
unbound: is.data.frame — a name the prelude does not declare
error detail
name: is.data.frame
gradual mode: typed
((x: any with { ptype: any, any }) -> "atomic"<> | "dataframe"<> | "mixed"<>)<>
timing: 0.055 s
source
list_col_type <- function(x) {
  is_data_frame <- is.data.frame(attr(x, "ptype", exact = TRUE)) ||
    (is.list(x) && all(map_lgl(x, is.data.frame)))
  is_atomic <- all(map_lgl(x, function(x) {
    is_atomic(x) || (is_list(x) && !is.object(x))
  }))

  if (is_data_frame) {
    "dataframe"
  } else if (is_atomic) {
    "atomic"
  } else {
    "mixed"
  }
}
R/nest-legacy.R:222

unnest_legacy.data.frame untypeable

unbound variable (line 142)
unbound: enquo — a name the prelude does not declare
error detail
name: enquo
timing: 0.175 s
source
unnest_legacy.data.frame <- function(
  data,
  ...,
  .drop = NA,
  .id = NULL,
  .sep = NULL,
  .preserve = NULL
) {
  preserve <- tidyselect::vars_select(names(data), !!enquo(.preserve))
  quos <- quos(...)
  if (is_empty(quos)) {
    list_cols <- names(data)[map_lgl(data, is_list)]
    list_cols <- setdiff(list_cols, preserve)

    quos <- syms(list_cols)
  }

  if (length(quos) == 0) {
    return(data)
  }

  nested <- dplyr::transmute(dplyr::ungroup(data), !!!quos)
  n <- map(nested, function(x) unname(map_int(x, NROW)))
  if (length(unique(n)) != 1) {
    cli::cli_abort("All nested columns must have the same number of elements.")
  }

  types <- map_chr(nested, list_col_type)
  nest_types <- split.default(nested, types)
  if (length(nest_types$mixed) > 0) {
    probs <- names(nest_types$mixed)
    cli::cli_abort(c(
      "Each column must either be a list of vectors or a list of data frames.",
      i = "Problems in: {.var {probs}}"
    ))
  }

  unnested_atomic <- imap(nest_types$atomic %||% list(), enframe, .id = .id)
  if (length(unnested_atomic) > 0) {
    unnested_atomic <- dplyr::bind_cols(unnested_atomic)
  }

  unnested_dataframe <- map(nest_types$dataframe %||% list(), function(.) {
    if (length(.) == 0L) {
      attr(., "ptype") %||% data.frame()
    } else {
      dplyr::bind_rows(., .id = .id)
    }
  })
  if (!is_null(.sep)) {
    unnested_dataframe <- imap(
      unnested_dataframe,
      function(df, name) {
        set_names(df, paste(name, names(df), sep = .sep))
      }
    )
  }
  if (length(unnested_dataframe) > 0) {
    unnested_dataframe <- dplyr::bind_cols(unnested_dataframe)
  }

  # Keep list columns by default, only if the rows aren't expanded
  if (identical(.drop, NA)) {
    n_in <- nrow(data)
    if (length(unnested_atomic)) {
      n_out <- nrow(unnested_atomic)
    } else {
      n_out <- nrow(unnested_dataframe)
    }
    .drop <- n_out != n_in
  }
  if (.drop) {
    is_atomic <- map_lgl(data, is_atomic)
    group_vars <- names(data)[is_atomic]
  } else {
    group_vars <- names(data)
  }
  group_vars <- setdiff(group_vars, names(nested))

  # Add list columns to be preserved
  group_vars <- union(group_vars, preserve)

  rest <- data[rep(seq_nrow(data), n[[1]]), group_vars, drop = FALSE]
  out <- dplyr::bind_cols(rest, unnested_atomic, unnested_dataframe)

  reconstruct_tibble(data, out)
}
R/nest-legacy.R:134
R/pack.R

strip_names untypeable

unbound variable (line 269)
unbound: vec_paste0 — one of the package’s own names, itself untyped
error detail
name: vec_paste0
timing: 0.031 s
source
strip_names <- function(df, base, names_sep) {
  base <- vec_paste0(base, names_sep)
  names <- names(df)

  has_prefix <- regexpr(base, names, fixed = TRUE) == 1L
  names[has_prefix] <- substr(
    names[has_prefix],
    nchar(base) + 1,
    nchar(names[has_prefix])
  )

  set_names(df, names)
}
R/pack.R:268

pack untypeabletyped

unbound variable (line 65)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
gradual mode: typed
((.data: any, ...: any, .names_sep: null?, .error_call: any?) -> any)<>
timing: 0.086 s
source
pack <- function(.data, ..., .names_sep = NULL, .error_call = current_env()) {
  check_data_frame(.data, call = .error_call)
  cols <- enquos(...)
  if (any(names2(cols) == "")) {
    cli::cli_abort("All elements of `...` must be named.", call = .error_call)
  }
  check_string(.names_sep, allow_null = TRUE, call = .error_call)

  cols <- with_indexed_errors(
    map(cols, function(col) {
      tidyselect::eval_select(
        expr = col,
        data = .data,
        allow_rename = FALSE,
        error_call = NULL
      )
    }),
    message = function(cnd) {
      cli::format_inline("In expression named {.arg {cnd$name}}:")
    },
    .error_call = .error_call
  )

  unpacked <- setdiff(names(.data), unlist(map(cols, names)))
  unpacked <- .data[unpacked]

  packed <- map(cols, ~ .data[.x])

  if (!is.null(.names_sep)) {
    packed <- imap(packed, strip_names, names_sep = .names_sep)
  }

  packed <- new_data_frame(packed, n = vec_size(.data))

  out <- vec_cbind(unpacked, packed, .error_call = .error_call)

  reconstruct_tibble(.data, out)
}
R/pack.R:65

check_inner_inner_duplicate skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.001 s
source
check_inner_inner_duplicate <- function(x, error_call = caller_env()) {
  n <- length(x)

  if (n == 0L || n == 1L) {
    # Nothing to duplicate across
    return(invisible())
  }

  outer <- names(x)
  x <- unname(x)

  inner <- map(x, names)
  inner <- map(inner, unique)

  outer <- vec_rep_each(outer, times = list_sizes(inner))
  inner <- list_unchop(inner, ptype = character())

  problems <- vec_duplicate_detect(inner)

  if (!any(problems)) {
    return(invisible())
  }

  outer <- vec_slice(outer, problems)
  inner <- vec_slice(inner, problems)

  split <- vec_split(outer, inner)

  inners <- split$key
  outers <- split$val

  bullets <- map2_chr(inners, outers, function(inner, outer) {
    cli::format_inline("{.code {inner}}, within {.code {outer}}.")
  })
  bullets <- set_names(bullets, "i")
  bullets <- cli::format_bullets_raw(bullets)
  bullets <- set_names(bullets, " ")

  message <- c(
    "Can't duplicate names within the affected columns.",
    x = "These names are duplicated:",
    bullets,
    i = "Use `names_sep` to disambiguate using the column name.",
    i = "Or use `names_repair` to specify a repair strategy."
  )

  cli::cli_abort(message, call = error_call)
}
R/pack.R:181

check_outer_inner_duplicate skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
check_outer_inner_duplicate <- function(x, outer, error_call = caller_env()) {
  # Names of unpacked columns will disappear so aren't considered
  outer <- setdiff(outer, names(x))

  inner <- map(x, names)
  inner <- map(inner, unique)

  problems <- map(inner, function(x) intersect(x, outer))
  problems <- vec_slice(problems, list_sizes(problems) != 0L)

  if (length(problems) == 0L) {
    return(invisible())
  }

  bullets <- map2_chr(problems, names(problems), function(inner, outer) {
    cli::format_inline("{.code {inner}}, from {.code {outer}}.")
  })
  bullets <- set_names(bullets, "i")
  bullets <- cli::format_bullets_raw(bullets)
  bullets <- set_names(bullets, " ")

  message <- c(
    "Can't duplicate names between the affected columns and the original data.",
    x = "These names are duplicated:",
    bullets,
    i = "Use `names_sep` to disambiguate using the column name.",
    i = "Or use `names_repair` to specify a repair strategy."
  )

  cli::cli_abort(message, call = error_call)
}
R/pack.R:230

rename_with_names_sep untypeabletyped

unbound variable (line 265)
unbound: set_names — a name the prelude does not declare
error detail
name: set_names
gradual mode: typed
((x: any, outer: any, names_sep: any) -> any)<>
timing: 0.029 s
source
rename_with_names_sep <- function(x, outer, names_sep) {
  inner <- names(x)
  names <- apply_names_sep(outer, inner, names_sep)
  set_names(x, names)
}
R/pack.R:262

unpack untypeabletyped

unbound variable (line 125)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
gradual mode: typed
((data: any, cols: any, ...: any, names_sep: null?, names_repair: any?, error_call: any?) -> any)<>
timing: 0.071 s
source
unpack <- function(
  data,
  cols,
  ...,
  names_sep = NULL,
  names_repair = "check_unique",
  error_call = current_env()
) {
  check_dots_empty0(...)
  check_data_frame(data, call = error_call)
  check_required(cols, call = error_call)
  check_string(names_sep, allow_null = TRUE, call = error_call)

  # Start from first principles to avoid issues in any subclass methods
  out <- tidyr_new_list(data)

  cols <- tidyselect::eval_select(
    expr = enquo(cols),
    data = data,
    allow_rename = FALSE,
    error_call = error_call
  )
  cols <- out[cols]
  cols <- cols[map_lgl(cols, is.data.frame)]

  cols_names <- names(cols)

  if (is.null(names_sep) && is_string(names_repair, "check_unique")) {
    # Only perform checks if user hasn't supplied `names_sep` or `names_repair`.
    # We let `vec_as_names()` catch any remaining problems.
    check_inner_inner_duplicate(cols, error_call = error_call)
    check_outer_inner_duplicate(cols, names(data), error_call = error_call)
  }

  if (!is.null(names_sep)) {
    out[cols_names] <- map2(
      cols,
      cols_names,
      rename_with_names_sep,
      names_sep = names_sep
    )
  }

  # Signal to tell `df_list()` to unpack
  names <- names(out)
  names[names %in% cols_names] <- ""
  names(out) <- names

  size <- vec_size(data)
  out <- df_list(!!!out, .size = size, .name_repair = "minimal")
  out <- tibble::new_tibble(out, nrow = size)

  names(out) <- vec_as_names(
    names = names(out),
    repair = names_repair,
    repair_arg = "names_repair",
    call = error_call
  )

  reconstruct_tibble(data, out)
}
R/pack.R:119
R/nest.R

is_default_key untypeabletyped

unbound variable (line 333)
unbound: maybe_missing — a name the prelude does not declare
error detail
name: maybe_missing
gradual mode: typed
((key: null) -> tt<>)<>
timing: 0.008 s
source
is_default_key <- function(key) {
  if (identical(maybe_missing(key), deprecated())) {
    # Temporary support for S3 method authors that set `.key = deprecated()`.
    # Remove this entire helper all methods have been updated.
    key <- NULL
  }

  is.null(key)
}
R/nest.R:332

check_key untypeabletyped

unbound variable (line 323)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((key: null, error_call: any?) -> "data"<>)<>
timing: 0.007 s
source
check_key <- function(key, error_call = caller_env()) {
  if (is_default_key(key)) {
    "data"
  } else {
    check_string(key, allow_empty = FALSE, arg = ".key", call = error_call)
    key
  }
}
R/nest.R:323

nest untypeable

unbound variable (line 121)
unbound: enquos — a name the prelude does not declare
error detail
name: enquos
timing: 0.087 s
source
nest <- function(.data, ..., .by = NULL, .key = NULL, .names_sep = NULL) {
  cols <- enquos(...)
  empty <- names2(cols) == ""

  if (any(empty)) {
    cols_good <- cols[!empty]
    cols_bad <- cols[empty]

    .key <- check_key(.key)

    if (length(cols_bad) == 1L) {
      cols_bad <- cols_bad[[1]]
      cols_fixed_expr <- expr(!!cols_bad)
    } else {
      cols_fixed_expr <- expr(c(!!!cols_bad))
    }

    cols_fixed_label <- as_label(cols_fixed_expr)
    cols_fixed <- quos(!!.key := !!cols_fixed_expr)

    cols <- c(cols_good, cols_fixed)

    lifecycle::deprecate_warn(
      when = "1.0.0",
      what = I("Supplying `...` without names"),
      details = c(
        i = "Please specify a name for each selection.",
        i = cli::format_inline("Did you want `{(.key)} = {cols_fixed_label}`?")
      ),
      always = TRUE
    )

    return(nest(.data, !!!cols, .by = {{ .by }}))
  }

  UseMethod("nest")
}
R/nest.R:120

warn_unused_key untypeabletyped

unbound variable (line 315)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((error_call: any?) -> any)<>
timing: 0.005 s
source
warn_unused_key <- function(error_call = caller_env()) {
  message <- c(
    "Can't supply both {.arg .key} and {.arg ...}.",
    i = "{.arg .key} will be ignored."
  )
  cli::cli_warn(message, call = error_call)
}
R/nest.R:315

nest_info untypeable

unbound variable (line 251)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
timing: 0.079 s
source
nest_info <- function(
  .data,
  ...,
  .by = NULL,
  .key = NULL,
  .error_call = caller_env()
) {
  by <- enquo(.by)

  cols <- enquos(...)
  n_cols <- length(cols)

  key <- check_key(.key, error_call = .error_call)

  if (n_cols != 0L && !is_default_key(.key)) {
    warn_unused_key(error_call = .error_call)
  }

  cols <- with_indexed_errors(
    map(cols, function(col) {
      names(tidyselect::eval_select(
        expr = col,
        data = .data,
        allow_rename = FALSE,
        error_call = NULL
      ))
    }),
    message = function(cnd) {
      cli::format_inline("In expression named {.arg {cnd$name}}:")
    },
    .error_call = .error_call
  )

  names <- names(.data)

  outer <- names(tidyselect::eval_select(
    expr = by,
    data = .data,
    allow_rename = FALSE,
    error_call = .error_call
  ))

  inner <- list_unchop(cols, ptype = character(), name_spec = zap())
  inner <- vec_unique(inner)

  if (n_cols == 0L) {
    # Derive `inner` names from `.by`
    inner <- setdiff(names, outer)
    cols <- list2(!!key := inner)
  }

  if (quo_is_null(by)) {
    # Derive `outer` names from `...`
    outer <- setdiff(names, inner)
  }

  # Regenerate quosures for `pack()`
  cols <- map(cols, function(col) {
    quo(all_of(!!col))
  })
  cols <- new_quosures(cols)

  list(
    cols = cols,
    inner = inner,
    outer = outer
  )
}
R/nest.R:246

nest.tbl_df skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.011 s
source
nest.tbl_df <- function(
  .data,
  ...,
  .by = NULL,
  .key = NULL,
  .names_sep = NULL
) {
  error_call <- current_env()

  info <- nest_info(.data, ..., .by = {{ .by }}, .key = .key)
  cols <- info$cols
  inner <- info$inner
  outer <- info$outer

  inner <- .data[inner]
  inner <- pack(
    inner,
    !!!cols,
    .names_sep = .names_sep,
    .error_call = error_call
  )

  out <- .data[outer]
  out <- vec_cbind(
    out,
    inner,
    .name_repair = "check_unique",
    .error_call = error_call
  )
  out <- reconstruct_tibble(.data, out)
  out <- chop(out, cols = all_of(names(cols)), error_call = error_call)

  # `nest()` currently doesn't return list-of columns
  for (name in names(cols)) {
    out[[name]] <- tidyr_new_list(out[[name]])
  }

  out
}
R/nest.R:182

nest.data.frame skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
nest.data.frame <- function(
  .data,
  ...,
  .by = NULL,
  .key = NULL,
  .names_sep = NULL
) {
  # The data frame print handles nested data frames poorly, so we want to
  # convert data frames (but not subclasses) to tibbles
  if (identical(class(.data), "data.frame")) {
    .data <- as_tibble(.data)
  }

  nest.tbl_df(
    .data,
    ...,
    .by = {{ .by }},
    .key = .key,
    .names_sep = .names_sep
  )
}
R/nest.R:159

nest.grouped_df skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
nest.grouped_df <- function(
  .data,
  ...,
  .by = NULL,
  .key = NULL,
  .names_sep = NULL
) {
  by <- enquo(.by)
  if (!quo_is_null(by)) {
    cli::cli_abort(
      "Can't supply {.arg .by} when {.arg .data} is a grouped data frame."
    )
  }

  if (missing(...)) {
    .key <- check_key(.key)
    cols <- setdiff(names(.data), dplyr::group_vars(.data))
    nest.tbl_df(.data, !!.key := all_of(cols), .names_sep = .names_sep)
  } else {
    nest.tbl_df(.data, ..., .key = .key, .names_sep = .names_sep)
  }
}
R/nest.R:223
R/pivot.R

check_pivot_spec untypeabletyped

unbound variable (line 32)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
∀'a. (((spec: { .name: 'a, .value: 'a, 'a }<~@"[", ...>, call: any?) -> { 'a }<>) & ((spec: { .name: any, .value: any, any }<@"[", ...>, call: any?) -> any))<>
timing: 0.069 s
source
check_pivot_spec <- function(spec, call = caller_env()) {
  check_data_frame(spec, call = call)

  if (!has_name(spec, ".name") || !has_name(spec, ".value")) {
    cli::cli_abort(
      "{.arg spec} must have {.var .name} and {.var .value} columns.",
      call = call
    )
  }

  check_character(spec$.name, call = call)
  if (vec_duplicate_any(spec$.name)) {
    cli::cli_abort("{.var spec$.name} must be unique.", call = call)
  }

  check_character(spec$.value, call = call)

  # Ensure `.name` and `.value` come first, in that order
  vars <- union(c(".name", ".value"), names(spec))
  spec <- spec[vars]

  spec
}
R/pivot.R:32

wrap_error_names untypeabletyped

unbound variable (line 61)
unbound: cnd_signal — a name the prelude does not declare
error detail
name: cnd_signal
gradual mode: typed
((code: any) -> any)<>
timing: 0.021 s
source
wrap_error_names <- function(code) {
  withCallingHandlers(
    code,
    vctrs_error_names = function(cnd) {
      cnd$arg <- "names_repair"
      cnd_signal(cnd)
    }
  )
}
R/pivot.R:56
R/pivot-long.R

pivot_longer untypeabletyped

unbound variable (line 154)
unbound: check_dots_used — a name the prelude does not declare
error detail
name: check_dots_used
gradual mode: typed
((data: any, cols: any, ...: any, cols_vary: any?, names_to: any?, names_prefix: any?, names_sep: any?, names_pattern: any?, names_ptypes: any?, names_transform: any?, names_repair: any?, values_to: any?, values_drop_na: any?, values_ptypes: any?, values_transform: any?) -> any)<>
timing: 0.076 s
source
pivot_longer <- function(
  data,
  cols,
  ...,
  cols_vary = "fastest",
  names_to = "name",
  names_prefix = NULL,
  names_sep = NULL,
  names_pattern = NULL,
  names_ptypes = NULL,
  names_transform = NULL,
  names_repair = "check_unique",
  values_to = "value",
  values_drop_na = FALSE,
  values_ptypes = NULL,
  values_transform = NULL
) {
  check_dots_used()
  UseMethod("pivot_longer")
}
R/pivot-long.R:137

build_longer_spec untypeable

unbound variable (line 371)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
timing: 0.202 s
source
build_longer_spec <- function(
  data,
  cols,
  ...,
  names_to = "name",
  values_to = "value",
  names_prefix = NULL,
  names_sep = NULL,
  names_pattern = NULL,
  names_ptypes = NULL,
  names_transform = NULL,
  error_call = current_env()
) {
  check_dots_empty0(...)
  check_data_frame(data, call = error_call)
  check_required(cols, call = error_call)
  check_character(names_to, allow_null = TRUE, call = error_call)

  cols <- tidyselect::eval_select(
    expr = enquo(cols),
    data = data[unique(names(data))],
    allow_rename = FALSE,
    error_call = error_call
  )
  cols <- names(cols)

  if (length(cols) == 0) {
    cli::cli_abort(
      "{.arg cols} must select at least one column.",
      call = error_call
    )
  }

  if (is.null(names_prefix)) {
    names <- cols
  } else {
    names <- gsub(vec_paste0("^", names_prefix), "", cols)
  }

  if (is.null(names_to)) {
    names_to <- character(0L)
  }

  n_names_to <- length(names_to)
  has_names_sep <- !is.null(names_sep)
  has_names_pattern <- !is.null(names_pattern)

  if (n_names_to == 0L) {
    names <- tibble::new_tibble(x = list(), nrow = length(names))
  } else if (n_names_to == 1L) {
    if (has_names_sep) {
      cli::cli_abort(
        "{.arg names_sep} can't be used with a length 1 {.arg names_to}.",
        call = error_call
      )
    }
    if (has_names_pattern) {
      names <- str_extract(
        names,
        names_to,
        regex = names_pattern,
        error_call = error_call
      )[[1]]
    }

    names <- tibble(!!names_to := names)
  } else {
    if (!xor(has_names_sep, has_names_pattern)) {
      cli::cli_abort(
        paste0(
          "If you supply multiple names in {.arg names_to} you must also supply one",
          " of {.arg names_sep} or {.arg names_pattern}."
        ),
        call = error_call
      )
    }

    if (has_names_sep) {
      names <- str_separate(
        names,
        names_to,
        sep = names_sep,
        error_call = error_call
      )
    } else {
      names <- str_extract(
        names,
        names_to,
        regex = names_pattern,
        error_call = error_call
      )
    }
  }

  if (".value" %in% names_to) {
    values_to <- NULL
  } else {
    vec_assert(values_to, ptype = character(), size = 1, call = error_call)
  }

  names_ptypes <- check_list_of_ptypes(
    names_ptypes,
    names(names),
    call = error_call
  )
  names_transform <- check_list_of_functions(
    names_transform,
    names(names),
    call = error_call
  )

  # Optionally, transform cols
  for (col in names(names_transform)) {
    f <- names_transform[[col]]
    names[[col]] <- f(names[[col]])
  }

  # Optionally, cast variables generated from columns
  for (col in names(names_ptypes)) {
    ptype <- names_ptypes[[col]]
    names[[col]] <- vec_cast(
      names[[col]],
      ptype,
      x_arg = col,
      call = error_call
    )
  }

  out <- tibble(.name = cols)
  out[[".value"]] <- values_to
  out <- vec_cbind(out, names)
  out
}
R/pivot-long.R:360

deduplicate_spec untypeable

unbound variable (line 509)
unbound: vec_duplicate_any — a name the prelude does not declare
error detail
name: vec_duplicate_any
timing: 0.110 s
source
deduplicate_spec <- function(spec, df) {
  # Ensure each .name has a unique output identifier
  key <- spec[setdiff(names(spec), ".name")]
  if (vec_duplicate_any(key)) {
    pos <- vec_group_loc(key)$loc
    seq <- vector("integer", length = nrow(spec))
    for (i in seq_along(pos)) {
      seq[pos[[i]]] <- seq_along(pos[[i]])
    }
    spec$.seq <- seq
  }

  # Match spec to data, handling duplicated column names
  col_id <- vec_match(names(df), spec$.name)
  has_match <- !is.na(col_id)

  if (!vec_duplicate_any(col_id[has_match])) {
    return(spec)
  }

  spec <- vec_slice(spec, col_id[has_match])
  # Need to use numeric indices because names only match first
  spec$.name <- seq_along(df)[has_match]

  pieces <- vec_split(seq_len(nrow(spec)), col_id[has_match])
  copy <- integer(nrow(spec))
  for (i in seq_along(pieces$val)) {
    idx <- pieces$val[[i]]
    copy[idx] <- seq_along(idx)
  }

  spec$.seq <- copy
  spec
}
R/pivot-long.R:506

drop_cols typed no call in domain

((df: <@"[", ...>, cols: CHR) -> any)<>
gradual mode: typed
((df: <@"[", ...>, cols: (~CHR)<@"-", ...>) | (df: <@"[", ...>, cols: CHR) | (df: <@"[", ...>, cols: dbl<~@"-", ...>) | (df: list<~@"[", ...>, cols: (~CHR)<@"-", ...>) | (df: list<~@"[", ...>, cols: dbl<~@"-", ...>) | (df: vec<~@"[", ...>, cols: (~CHR)<@"-", ...>) | (df: vec<~@"[", ...>, cols: dbl<~@"-", ...>) -> any)<>
timing: 0.102 s
fuzzing: 0 inside (none) · 0 outside (none)
source
drop_cols <- function(df, cols) {
  if (is.character(cols)) {
    df[setdiff(names(df), cols)]
  } else if (is.integer(cols)) {
    df[-cols]
  } else {
    cli::cli_abort("Invalid input", .internal = TRUE)
  }
}
R/pivot-long.R:494

pivot_longer_spec untypeable

unbound variable (line 251)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
timing: 0.173 s
source
pivot_longer_spec <- function(
  data,
  spec,
  ...,
  cols_vary = "fastest",
  names_repair = "check_unique",
  values_drop_na = FALSE,
  values_ptypes = NULL,
  values_transform = NULL,
  error_call = current_env()
) {
  check_dots_empty0(...)

  spec <- check_pivot_spec(spec, call = error_call)
  spec <- deduplicate_spec(spec, data)

  cols_vary <- arg_match0(
    arg = cols_vary,
    values = c("fastest", "slowest"),
    error_call = error_call
  )

  # Quick hack to ensure that split() preserves order
  v_fct <- factor(spec$.value, levels = unique(spec$.value))
  values <- split(spec$.name, v_fct)
  value_names <- names(values)
  value_keys <- split(spec[-(1:2)], v_fct)
  keys <- vec_unique(spec[-(1:2)])

  values_ptypes <- check_list_of_ptypes(
    values_ptypes,
    value_names,
    call = error_call
  )
  values_transform <- check_list_of_functions(
    values_transform,
    value_names,
    call = error_call
  )

  vals <- set_names(vec_init(list(), length(values)), value_names)
  for (value in value_names) {
    cols <- values[[value]]
    col_id <- vec_match(value_keys[[value]], keys)

    n_val_cols <- nrow(keys)

    val_cols <- vec_init(list(), n_val_cols)
    val_cols[col_id] <- unname(as.list(data[cols]))
    val_cols[-col_id] <- list(rep(NA, nrow(data)))

    if (has_name(values_transform, value)) {
      val_cols <- map(val_cols, values_transform[[value]])
    }

    # Name inputs that came from `data`, just for good error messages when
    # taking the common type and casting
    names <- vec_rep("", times = n_val_cols)
    names[col_id] <- cols

    names(val_cols) <- names
    val_type <- vec_ptype_common(
      !!!val_cols[col_id],
      .ptype = values_ptypes[[value]],
      .call = error_call
    )
    val_cols <- vec_cast_common(
      !!!val_cols,
      .to = val_type,
      .call = error_call
    )
    val_cols <- unname(val_cols)

    if (cols_vary == "slowest") {
      vals[[value]] <- list_unchop(val_cols, ptype = val_type)
    } else if (cols_vary == "fastest") {
      vals[[value]] <- vec_interleave(!!!val_cols, .ptype = val_type)
    } else {
      cli::cli_abort("Unknown {.arg cols_vary} value.", .internal = TRUE)
    }
  }
  vals <- as_tibble(vals)

  # Join together data, keys, and vals to produce final tibble
  data_cols <- drop_cols(as_tibble(data, .name_repair = "minimal"), spec$.name)

  times_keys <- vec_size(data_cols)
  times_data_cols <- vec_size(keys)

  if (cols_vary == "slowest") {
    data_cols <- vec_rep(data_cols, times_data_cols)
    keys <- vec_rep_each(keys, times_keys)
  } else if (cols_vary == "fastest") {
    data_cols <- vec_rep_each(data_cols, times_data_cols)
    keys <- vec_rep(keys, times_keys)
  } else {
    cli::cli_abort("Unknown {.arg cols_vary} value.", .internal = TRUE)
  }

  out <- wrap_error_names(vec_cbind(
    data_cols,
    keys,
    vals,
    .name_repair = names_repair,
    .error_call = error_call
  ))

  if (values_drop_na && vec_any_missing(vals)) {
    out <- vec_slice(out, !vec_detect_missing(vals))
  }

  out$.seq <- NULL

  reconstruct_tibble(data, out)
}
R/pivot-long.R:242

pivot_longer.data.frame untypeabletyped

unbound variable (line 186)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
gradual mode: typed
((data: any, cols: any, ...: any, cols_vary: any?, names_to: any?, names_prefix: any?, names_sep: any?, names_pattern: any?, names_ptypes: any?, names_transform: any?, names_repair: any?, values_to: any?, values_drop_na: any?, values_ptypes: any?, values_transform: any?) -> any)<>
timing: 0.078 s
source
pivot_longer.data.frame <- function(
  data,
  cols,
  ...,
  cols_vary = "fastest",
  names_to = "name",
  names_prefix = NULL,
  names_sep = NULL,
  names_pattern = NULL,
  names_ptypes = NULL,
  names_transform = NULL,
  names_repair = "check_unique",
  values_to = "value",
  values_drop_na = FALSE,
  values_ptypes = NULL,
  values_transform = NULL
) {
  spec <- build_longer_spec(
    data = data,
    cols = {{ cols }},
    names_to = names_to,
    values_to = values_to,
    names_prefix = names_prefix,
    names_sep = names_sep,
    names_pattern = names_pattern,
    names_ptypes = names_ptypes,
    names_transform = names_transform,
    error_call = current_env()
  )

  pivot_longer_spec(
    data = data,
    spec = spec,
    cols_vary = cols_vary,
    names_repair = names_repair,
    values_drop_na = values_drop_na,
    values_ptypes = values_ptypes,
    values_transform = values_transform,
    error_call = current_env()
  )
}
R/pivot-long.R:159
R/pivot-wide.R

pivot_wider untypeabletyped

unbound variable (line 163)
unbound: name — a name the prelude does not declare
error detail
name: name
gradual mode: typed
((data: any, ...: any, id_cols: any?, id_expand: any?, names_from: any?, names_prefix: any?, names_sep: any?, names_glue: any?, names_sort: any?, names_vary: any?, names_expand: any?, names_repair: any?, values_from: any?, values_fill: any?, values_fn: any?, unused_fn: any?) -> any)<>
timing: 0.057 s
source
pivot_wider <- function(
  data,
  ...,
  id_cols = NULL,
  id_expand = FALSE,
  names_from = name,
  names_prefix = "",
  names_sep = "_",
  names_glue = NULL,
  names_sort = FALSE,
  names_vary = "fastest",
  names_expand = FALSE,
  names_repair = "check_unique",
  values_from = value,
  values_fill = NULL,
  values_fn = NULL,
  unused_fn = NULL
) {
  # TODO: Use `check_dots_used()` after removing the `id_cols` compat behavior
  UseMethod("pivot_wider")
}
R/pivot-wide.R:158

stop_id_cols_oob untypeabletyped

unbound variable (line 670)
unbound: cli::cli_abort — a name the prelude does not declare
error detail
name: cli::cli_abort
gradual mode: typed
((i: any, arg: any, call: any) -> any)<>
timing: 0.024 s
source
stop_id_cols_oob <- function(i, arg, call) {
  cli::cli_abort(
    c(
      "`id_cols` can't select a column already selected by `{arg}`.",
      i = "Column `{i}` has already been selected."
    ),
    parent = NA,
    call = call
  )
}
R/pivot-wide.R:669

rethrow_id_cols_oob untypeabletyped

unbound variable (line 656)
unbound: is_string — a name the prelude does not declare
error detail
name: is_string
gradual mode: typed
((cnd: vec<~@"[[", ...>, names_from_cols: vec | null, values_from_cols: vec | null, call: any) | (cnd: { i: vec | null, any }<~@"[[", ...>, names_from_cols: vec | null, values_from_cols: vec | null, call: any) | (cnd: { vec | null }<~@"[[", ...>, names_from_cols: vec | null, values_from_cols: vec | null, call: any) -> any)<>
timing: 0.241 s
source
rethrow_id_cols_oob <- function(cnd, names_from_cols, values_from_cols, call) {
  i <- cnd[["i"]]

  if (is_string(i)) {
    # Try to throw our custom error
    if (i %in% names_from_cols) {
      stop_id_cols_oob(i, "names_from", call = call)
    } else if (i %in% values_from_cols) {
      stop_id_cols_oob(i, "values_from", call = call)
    }
  }

  # Otherwise fall through and throw standard tidyselect error
  zap()
}
R/pivot-wide.R:653

select_wider_id_cols untypeabletyped

unbound variable (line 626)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((data: <@"[", ...>, id_cols: any?, names_from_cols: (vec | null)?, values_from_cols: (vec | null)?, error_call: any?) -> CHR<> | null)<>
timing: 0.071 s
source
select_wider_id_cols <- function(
  data,
  id_cols = NULL,
  names_from_cols = character(),
  values_from_cols = character(),
  error_call = caller_env()
) {
  id_cols <- enquo(id_cols)

  # Remove known non-id-cols so they are never selected
  data <- data[setdiff(names(data), c(names_from_cols, values_from_cols))]

  if (quo_is_null(id_cols)) {
    # Default selects everything in `data` after non-id-cols have been removed
    return(names(data))
  }

  try_fetch(
    id_cols <- tidyselect::eval_select(
      enquo(id_cols),
      data,
      allow_rename = FALSE,
      error_call = error_call
    ),
    vctrs_error_subscript_oob = function(cnd) {
      rethrow_id_cols_oob(cnd, names_from_cols, values_from_cols, error_call)
    }
  )

  names(id_cols)
}
R/pivot-wide.R:621

build_wider_id_cols_expr untypeabletyped

unbound variable (line 592)
unbound: name — a name the prelude does not declare
error detail
name: name
gradual mode: typed
((data: any, id_cols: any?, names_from: any?, values_from: any?, error_call: any?) -> any)<>
timing: 0.064 s
source
build_wider_id_cols_expr <- function(
  data,
  id_cols = NULL,
  names_from = name,
  values_from = value,
  error_call = caller_env()
) {
  names_from <- tidyselect::eval_select(
    enquo(names_from),
    data,
    allow_rename = FALSE,
    error_call = error_call
  )

  values_from <- tidyselect::eval_select(
    enquo(values_from),
    data,
    allow_rename = FALSE,
    error_call = error_call
  )

  out <- select_wider_id_cols(
    data = data,
    id_cols = {{ id_cols }},
    names_from_cols = names(names_from),
    values_from_cols = names(values_from),
    error_call = error_call
  )

  expr(c(!!!out))
}
R/pivot-wide.R:589

build_wider_spec untypeable

unbound variable (line 505)
unbound: name — a name the prelude does not declare
error detail
name: name
timing: 0.114 s
source
build_wider_spec <- function(
  data,
  ...,
  names_from = name,
  values_from = value,
  names_prefix = "",
  names_sep = "_",
  names_glue = NULL,
  names_sort = FALSE,
  names_vary = "fastest",
  names_expand = FALSE,
  error_call = current_env()
) {
  check_dots_empty0(...)

  names_from <- tidyselect::eval_select(
    enquo(names_from),
    data,
    allow_rename = FALSE,
    allow_empty = FALSE,
    error_call = error_call
  )
  values_from <- tidyselect::eval_select(
    enquo(values_from),
    data,
    allow_rename = FALSE,
    allow_empty = FALSE,
    error_call = error_call
  )

  check_string(names_prefix, call = error_call)
  check_string(names_sep, call = error_call)
  check_string(names_glue, allow_null = TRUE, call = error_call)
  check_bool(names_sort, call = error_call)
  check_bool(names_expand, call = error_call)

  names_vary <- arg_match0(
    arg = names_vary,
    values = c("fastest", "slowest"),
    arg_nm = "names_vary",
    error_call = error_call
  )

  data <- as_tibble(data)
  data <- data[names_from]

  if (names_expand) {
    # `expand()` always does sort + unique
    row_ids <- expand(data, !!!syms(names(data)))
  } else {
    row_ids <- vec_unique(data)

    if (names_sort) {
      row_ids <- vec_sort(row_ids)
    }
  }

  row_names <- exec(paste, !!!row_ids, sep = names_sep)

  out <- tibble(
    .name = vec_paste0(names_prefix, row_names)
  )

  if (length(values_from) == 1) {
    out$.value <- names(values_from)
  } else {
    if (names_vary == "fastest") {
      out <- vec_rep(out, vec_size(values_from))
      out$.value <- vec_rep_each(names(values_from), vec_size(row_ids))
      row_ids <- vec_rep(row_ids, vec_size(values_from))
    } else {
      out <- vec_rep_each(out, vec_size(values_from))
      out$.value <- vec_rep(names(values_from), vec_size(row_ids))
      row_ids <- vec_rep_each(row_ids, vec_size(values_from))
    }

    out$.name <- vec_paste0(out$.value, names_sep, out$.name)
  }

  out <- vec_cbind(out, as_tibble(row_ids), .name_repair = "minimal")
  if (!is.null(names_glue)) {
    out$.name <- as.character(glue::glue_data(out, names_glue))
  }

  out
}
R/pivot-wide.R:502

warn_deprecated_unnamed_id_cols untypeabletyped

unbound variable (line 712)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((id_cols: any, user_env: any?) -> any)<>
timing: 0.007 s
source
warn_deprecated_unnamed_id_cols <- function(id_cols, user_env = caller_env(2)) {
  id_cols <- as_label(id_cols)

  lifecycle::deprecate_warn(
    when = "1.3.0",
    what = I(cli::format_inline(
      "Specifying the {.arg id_cols} argument by position"
    )),
    details = cli::format_inline(
      "Please explicitly name {.arg id_cols}, like {.code id_cols = {id_cols}}."
    ),
    always = TRUE,
    user_env = user_env
  )
}
R/pivot-wide.R:712

compat_id_cols skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
compat_id_cols <- function(
  id_cols,
  ...,
  fn_call,
  error_call = caller_env(),
  user_env = caller_env(2)
) {
  dots <- enquos(...)

  # If `id_cols` is specified by name by the user, it will show up in the call.
  # Otherwise, default args don't show up in the call so it won't be there.
  user_specified_id_cols <- "id_cols" %in% names(fn_call)

  # For compatibility (#1353), assign the first value of `...` to `id_cols` if:
  # - The user didn't specify `id_cols`.
  # - There is exactly 1 unnamed element in `...`.
  use_compat_id_cols <-
    !user_specified_id_cols &&
    length(dots) == 1L &&
    !is_named(dots)

  if (use_compat_id_cols) {
    id_cols <- dots[[1L]]
    warn_deprecated_unnamed_id_cols(id_cols, user_env = user_env)
  } else {
    id_cols <- enquo(id_cols)
    check_dots_empty0(..., call = error_call)
  }

  id_cols
}
R/pivot-wide.R:680

backtick_if_not_syntactic untypeabletyped

unbound variable (line 801)
unbound: make.names — a name the prelude does not declare
error detail
name: make.names
gradual mode: typed
((x: any) -> any)<>
timing: 0.013 s
source
backtick_if_not_syntactic <- function(x) {
  ok <- make.names(x) == x
  ok[is.na(x)] <- FALSE

  x[!ok] <- glue::backtick(x[!ok])

  x
}
R/pivot-wide.R:800

chop_rectangular_df untypeabletyped

unbound variable (line 769)
unbound: vec_size — a name the prelude does not declare
error detail
name: vec_size
gradual mode: typed
((x: any, names: any) -> any)<>
timing: 0.014 s
source
chop_rectangular_df <- function(x, names) {
  n_col <- vec_size(names)
  n_row <- vec_size(x) / n_col

  indices <- vector("list", n_col)

  start <- 1L
  stop <- n_row

  for (i in seq_len(n_col)) {
    indices[[i]] <- seq2(start, stop)
    start <- start + n_row
    stop <- stop + n_row
  }

  out <- vec_chop(x, indices)
  names(out) <- names
  tibble::new_tibble(out, nrow = n_row)
}
R/pivot-wide.R:768

is_scalar typed accepts outside

((x: null) -> ff<>)<>
gradual mode: typed
(((x: null) -> ff<>)&((x: ~null) -> ff<> | tt<>))<>
timing: 0.046 s
fuzzing: 2 inside (2 ok) · 7 outside (6 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:listis_scalar(list())ff<> with { }

Side effects

gzfile
source
is_scalar <- function(x) {
  if (is.null(x)) {
    return(FALSE)
  }

  if (vec_is_list(x)) {
    (vec_size(x) == 1) && !have_name(x)
  } else {
    vec_size(x) == 1
  }
}
R/pivot-wide.R:788

value_summarize untypeabletyped

unbound variable (line 736)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((value: any, value_locs: any, value_name: any, fn: any, fn_name: any, error_call: any?) -> any)<>
timing: 0.053 s
source
value_summarize <- function(
  value,
  value_locs,
  value_name,
  fn,
  fn_name,
  error_call = caller_env()
) {
  value <- vec_chop(value, value_locs)

  if (identical(fn, list)) {
    # The no-op case, for performance
    return(value)
  }

  value <- map(value, fn)

  sizes <- list_sizes(value)
  invalid_sizes <- sizes != 1L

  if (any(invalid_sizes)) {
    size <- sizes[invalid_sizes][[1]]

    cli::cli_abort(
      c(
        "Applying {.arg {fn_name}} to {.var {value_name}} must result in a single summary value per key.",
        i = "Applying {.arg {fn_name}} resulted in a vector of length {size}."
      ),
      call = error_call
    )
  }

  value <- list_unchop(value)

  value
}
R/pivot-wide.R:730

pivot_wider_spec untypeable

unbound variable (line 304)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
timing: 2.81 s
source
pivot_wider_spec <- function(
  data,
  spec,
  ...,
  names_repair = "check_unique",
  id_cols = NULL,
  id_expand = FALSE,
  values_fill = NULL,
  values_fn = NULL,
  unused_fn = NULL,
  error_call = current_env()
) {
  check_dots_empty0(...)
  check_data_frame(data, call = error_call)

  spec <- check_pivot_spec(spec, call = error_call)
  check_bool(id_expand, call = error_call)

  names_from_cols <- names(spec)[-(1:2)]
  values_from_cols <- vec_unique(spec$.value)

  id_cols <- select_wider_id_cols(
    data = data,
    id_cols = {{ id_cols }},
    names_from_cols = names_from_cols,
    values_from_cols = values_from_cols,
    error_call = error_call
  )

  values_fn <- check_list_of_functions(
    values_fn,
    values_from_cols,
    call = error_call
  )

  unused_cols <- setdiff(
    names(data),
    c(id_cols, names_from_cols, values_from_cols)
  )
  unused_fn <- check_list_of_functions(
    unused_fn,
    unused_cols,
    call = error_call
  )
  unused_cols <- names(unused_fn)

  if (is.null(values_fill)) {
    values_fill <- list()
  } else if (is_scalar(values_fill)) {
    values_fill <- rep_named(values_from_cols, list(values_fill))
  } else if (!vec_is_list(values_fill)) {
    cli::cli_abort(
      "{.arg values_fill} must be {.code NULL}, a scalar, or a named list, not {.obj_type_friendly {values_fill}}.",
      call = error_call
    )
  }
  values_fill <- values_fill[intersect(names(values_fill), values_from_cols)]

  input <- data
  # Early conversion to tibble because data.table returns zero rows if
  # zero cols are selected. Also want to avoid the grouped-df behavior
  # of `complete()`.
  data <- as_tibble(data)
  data <- data[vec_unique(c(
    id_cols,
    names_from_cols,
    values_from_cols,
    unused_cols
  ))]

  if (id_expand) {
    data <- complete(
      data,
      !!!syms(id_cols),
      fill = values_fill,
      explicit = FALSE
    )
  }

  # Figure out rows in output
  rows <- data[id_cols]
  row_id <- vec_group_id(rows)
  nrow <- attr(row_id, "n")
  rows <- vec_slice(rows, vec_unique_loc(row_id))

  n_unused_fn <- length(unused_fn)

  unused <- vector("list", length = n_unused_fn)
  names(unused) <- unused_cols

  if (n_unused_fn > 0L) {
    # This can be expensive, only compute if we are using `unused_fn`
    unused_locs <- vec_group_loc(row_id)$loc
  }

  for (i in seq_len(n_unused_fn)) {
    unused_col <- unused_cols[[i]]
    unused_fn_i <- unused_fn[[i]]

    unused_value <- data[[unused_col]]

    unused[[i]] <- value_summarize(
      value = unused_value,
      value_locs = unused_locs,
      value_name = unused_col,
      fn = unused_fn_i,
      fn_name = "unused_fn",
      error_call = error_call
    )
  }

  unused <- tibble::new_tibble(unused, nrow = nrow)

  duplicate_names <- character(0L)

  value_specs <- unname(split(spec, spec$.value))
  value_out <- vec_init(list(), length(value_specs))

  for (i in seq_along(value_out)) {
    value_spec <- value_specs[[i]]
    value_name <- value_spec$.value[[1]]
    value <- data[[value_name]]

    cols <- data[names(value_spec)[-(1:2)]]
    col_id <- vec_match(as_tibble(cols), value_spec[-(1:2)])
    value_id <- data.frame(row = row_id, col = col_id)

    value_fn <- values_fn[[value_name]]

    if (is.null(value_fn) && vec_duplicate_any(value_id)) {
      # There are unhandled duplicates. Handle them with `list()` and warn.
      value_fn <- list
      duplicate_names <- c(duplicate_names, value_name)
    }

    if (!is.null(value_fn)) {
      result <- vec_group_loc(value_id)
      value_id <- result$key
      value_locs <- result$loc

      value <- value_summarize(
        value = value,
        value_locs = value_locs,
        value_name = value_name,
        fn = value_fn,
        fn_name = "values_fn",
        error_call = error_call
      )
    }

    ncol <- nrow(value_spec)

    fill <- values_fill[[value_name]]
    if (is.null(fill)) {
      out <- vec_init(value, nrow * ncol)
    } else {
      stopifnot(vec_size(fill) == 1)
      fill <- vec_cast(fill, value, call = error_call)
      out <- vec_rep_each(fill, nrow * ncol)
    }
    out <- vec_assign(out, value_id$row + nrow * (value_id$col - 1L), value)

    value_out[[i]] <- chop_rectangular_df(out, value_spec$.name)
  }

  if (length(duplicate_names) > 0L) {
    duplicate_names <- glue::backtick(duplicate_names)
    duplicate_names <- glue::glue_collapse(
      duplicate_names,
      sep = ", ",
      last = " and "
    )

    group_cols <- c(id_cols, names_from_cols)
    group_cols <- backtick_if_not_syntactic(group_cols)
    group_cols <- glue::glue_collapse(group_cols, sep = ", ")

    cli::cli_warn(c(
      "Values from {duplicate_names} are not uniquely identified; output will contain list-cols.",
      "*" = "Use `values_fn = list` to suppress this warning.",
      "*" = "Use `values_fn = {{summary_fun}}` to summarise duplicates.",
      "*" = "Use the following dplyr code to identify duplicates.",
      " " = "  {{data}} |>",
      " " = "    dplyr::summarise(n = dplyr::n(), .by = c({group_cols})) |>",
      " " = "    dplyr::filter(n > 1L)"
    ))
  }

  # `check_pivot_spec()` ensures `.name` is unique. Name repair shouldn't be needed.
  values <- vec_cbind(!!!value_out, .name_repair = "minimal")

  # Recreate desired column order of the new spec columns (#569)
  values <- values[spec$.name]

  out <- wrap_error_names(vec_cbind(
    rows,
    values,
    unused,
    .name_repair = names_repair,
    .error_call = error_call
  ))
R/pivot-wide.R:294

pivot_wider.data.frame skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.020 s
source
pivot_wider.data.frame <- function(
  data,
  ...,
  id_cols = NULL,
  id_expand = FALSE,
  names_from = name,
  names_prefix = "",
  names_sep = "_",
  names_glue = NULL,
  names_sort = FALSE,
  names_vary = "fastest",
  names_expand = FALSE,
  names_repair = "check_unique",
  values_from = value,
  values_fill = NULL,
  values_fn = NULL,
  unused_fn = NULL
) {
  names_from <- enquo(names_from)
  values_from <- enquo(values_from)

  spec <- build_wider_spec(
    data = data,
    names_from = !!names_from,
    values_from = !!values_from,
    names_prefix = names_prefix,
    names_sep = names_sep,
    names_glue = names_glue,
    names_sort = names_sort,
    names_vary = names_vary,
    names_expand = names_expand,
    error_call = current_env()
  )

  id_cols <- compat_id_cols(
    id_cols = {{ id_cols }},
    ...,
    fn_call = match.call(expand.dots = FALSE)
  )

  id_cols <- build_wider_id_cols_expr(
    data = data,
    id_cols = !!id_cols,
    names_from = !!names_from,
    values_from = !!values_from
  )

  pivot_wider_spec(
    data = data,
    spec = spec,
    id_cols = !!id_cols,
    id_expand = id_expand,
    names_repair = names_repair,
    values_fill = values_fill,
    values_fn = values_fn,
    unused_fn = unused_fn,
    error_call = current_env()
  )
}
R/pivot-wide.R:181
R/separate-longer.R

map_unchop untypeabletyped

unbound variable (line 96)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((data: any, cols: any, fun: arrow, ...: any, .keep_empty: any?, .error_call: any?) -> any)<>
timing: 0.052 s
source
map_unchop <- function(
  data,
  cols,
  fun,
  ...,
  .keep_empty = FALSE,
  .error_call = caller_env()
) {
  cols <- tidyselect::eval_select(
    enquo(cols),
    data = data,
    allow_rename = FALSE,
    allow_empty = FALSE,
    error_call = .error_call
  )
  col_names <- names(cols)

  for (col in col_names) {
    data[[col]] <- fun(data[[col]], ...)
  }

  unchop(
    data = data,
    cols = all_of(col_names),
    keep_empty = .keep_empty,
    ptype = character(),
    error_call = .error_call
  )
}
R/separate-longer.R:90

separate_longer_delim untypeabletyped

unbound variable (line 32)
unbound: check_installed — a name the prelude does not declare
error detail
name: check_installed
gradual mode: typed
((data: any, cols: any, delim: any, ...: any) -> any)<>
timing: 0.027 s
source
separate_longer_delim <- function(data, cols, delim, ...) {
  check_installed("stringr")
  check_data_frame(data)
  check_required(cols)
  check_string(delim)
  check_dots_empty()

  if (is_bare_string(delim)) {
    delim <- stringr::fixed(delim)
  }

  map_unchop(data, {{ cols }}, stringr::str_split, pattern = delim)
}
R/separate-longer.R:31

str_split_length untypeabletyped

unbound variable (line 80)
unbound: stringr::str_length — a name the prelude does not declare
error detail
name: stringr::str_length
gradual mode: typed
((x: any, width: any?) -> any)<>
timing: 0.037 s
source
str_split_length <- function(x, width = 1) {
  if (length(x) == 0L) {
    return(list())
  }

  max_length <- max(stringr::str_length(x))
  idx <- seq(1, max_length, by = width)

  pieces <- stringr::str_sub_all(x, cbind(idx, length = width))
  pieces <- map(pieces, function(x) x[x != ""])
  pieces
}
R/separate-longer.R:75

separate_longer_position untypeabletyped

unbound variable (line 60)
unbound: check_installed — a name the prelude does not declare
error detail
name: check_installed
gradual mode: typed
((data: any, cols: any, width: any, ...: any, keep_empty: any?) -> any)<>
timing: 0.017 s
source
separate_longer_position <- function(
  data,
  cols,
  width,
  ...,
  keep_empty = FALSE
) {
  check_installed("stringr")
  check_data_frame(data)
  check_required(cols)
  check_number_whole(width, min = 1)
  check_dots_empty()

  map_unchop(
    data,
    {{ cols }},
    str_split_length,
    width = width,
    .keep_empty = keep_empty
  )
}
R/separate-longer.R:53
R/separate-wider.R

map_unpack untypeabletyped

unbound variable (line 536)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((data: any, cols: any, fun: arrow, names_sep: any, names_repair: any, error_call: any?) -> any)<>
timing: 0.096 s
source
map_unpack <- function(
  data,
  cols,
  fun,
  names_sep,
  names_repair,
  error_call = caller_env()
) {
  cols <- tidyselect::eval_select(
    enquo(cols),
    data = data,
    allow_rename = FALSE,
    allow_empty = FALSE,
    error_call = error_call
  )
  col_names <- names(cols)

  for (col in col_names) {
    data[[col]] <- fun(data[[col]], col)
  }

  unpack(
    data = data,
    cols = all_of(col_names),
    names_sep = names_sep,
    names_repair = names_repair,
    error_call = error_call
  )
}
R/separate-wider.R:530

check_df_alignment skipped

error detail
File "Rsem/lang/PAst.ml", line 210, characters 14-20: Assertion failed
timing: 0.000 s
source
check_df_alignment <- function(
  col,
  p,
  type,
  sizes,
  too_few,
  too_many,
  advice_short = NULL,
  advice_long = NULL,
  call = caller_env()
) {
  n_short <- sum(sizes < p, na.rm = TRUE)
  n_long <- sum(sizes > p, na.rm = TRUE)

  error_short <- too_few == "error" && n_short > 0
  error_long <- too_many == "error" && n_long > 0

  if (!error_short && !error_long) {
    return()
  }

  cli::cli_abort(
    c(
      "Expected {p} {type} in each element of {.var {col}}.",
      "!" = if (error_short) "{n_short} value{?s} {?was/were} too short.",
      if (error_short) advice_short,
      "!" = if (error_long) "{n_long} value{?s} {?was/were} too long.",
      if (error_long) advice_long
    ),
    call = call
  )
}
R/separate-wider.R:627

debug_name typed any: col, var fuzz ok

(((col: any, names_sep: null, var: any) | (col: any, names_sep: ~null, var: any) -> CHR<>)&((col: vec1, names_sep: null, var: vec1) | (col: vec1, names_sep: vec1, var: vec1) -> CHR1<>))<>
timing: 0.202 s
fuzzing: 8 inside (4 ok, 4 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
debug_name(NULL, NULL, function(...) list())error_typebase::paste0: cannot coerce type 'closure' to vector of type 'character'
debug_name("col" = new.env(), "names_sep" = new.env(), "var" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_typebase::paste0: environments cannot be coerced to other types
debug_name(NULL, "names_sep" = NULL, "var" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_typebase::paste0: cannot coerce type 'externalptr' to vector of type 'character'
debug_name(new.env(), local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "var" = quote(f(x)))error_typebase::paste0: environments cannot be coerced to other types
source
debug_name <- function(col, names_sep, var) {
  paste0(col, names_sep %||% "_", var)
}
R/separate-wider.R:666

df_align_transpose untypeable

unbound variable (line 584)
unbound: list_sizes — a name the prelude does not declare
error detail
name: list_sizes
timing: 0.087 s
source
df_align_transpose <- function(x, p, align_direction = "start") {
  sizes <- list_sizes(x)
  # Find the start location of each piece
  starts <- cumsum(c(1L, sizes[-length(sizes)]))

  # Combine all pieces sequentially, zapping names for performance.
  x <- list_unchop(x, ptype = character(), name_spec = zap())

  indices <- vector("list", p)
  if (align_direction == "start") {
    # General idea is to use the `starts` to slice with, replacing them with
    # `NA` when we are too short, and then advancing the `starts` by 1 at each
    # iteration.
    for (i in seq_len(p)) {
      small <- sizes < i

      index <- starts
      index[small] <- NA_integer_
      indices[[i]] <- index

      starts <- starts + 1L
    }
  } else {
    # `"end"` is a little tricky because we have to hold the start
    # location constant if we couldn't use it because the piece was too small.
    # Pieces that are too large are automatically ignored.
    gap <- sizes - p

    for (i in seq_len(p)) {
      small <- gap < 0
      not_small <- !small

      index <- starts
      index[small] <- NA_integer_
      indices[[i]] <- index

      starts[not_small] <- starts[not_small] + 1L
      gap <- gap + 1L
    }
  }

  vec_chop(x, indices)
}
R/separate-wider.R:583

df_align untypeabletyped

unbound variable (line 566)
unbound: vec_check_list — a name the prelude does not declare
error detail
name: vec_check_list
gradual mode: typed
((x: any, names: <@"[", ...>, align_direction: any?) | (x: any, names: list<~@"[", ...>, align_direction: any?) | (x: any, names: vec<~@"[", ...>, align_direction: any?) -> any)<>
timing: 0.052 s
source
df_align <- function(
  x,
  names,
  align_direction = c("start", "end")
) {
  vec_check_list(x)
  if (length(x) == 0) {
    return(new_data_frame(rep_named(names, list(character())), size = 0))
  }

  align_direction <- arg_match(align_direction)

  n <- length(x)
  p <- length(names)

  out <- df_align_transpose(x, p, align_direction = align_direction)
  out <- out[!is.na(names)]
  names(out) <- names[!is.na(names)]

  new_data_frame(out, size = n)
}
R/separate-wider.R:561

separate_warn_debug untypeabletyped

unbound variable (line 663)
unbound: cli::cli_warn — a name the prelude does not declare
error detail
name: cli::cli_warn
gradual mode: typed
((col: any, names_sep: any, vars: any) -> any)<>
timing: 0.050 s
source
separate_warn_debug <- function(col, names_sep, vars) {
  vars <- debug_name(col, names_sep, vars)

  cli::cli_warn("Debug mode activated: adding variables {.var {vars}}.")
}
R/separate-wider.R:660

str_separate_wider_delim untypeabletimeout

unbound variable (line 192)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: timeout
timing: 0.577 s
source
str_separate_wider_delim <- function(
  x,
  col,
  names,
  delim,
  names_sep = NULL,
  too_few = "error",
  too_many = "error",
  cols_remove = TRUE,
  error_call = caller_env()
) {
  if (is_bare_string(delim)) {
    delim <- stringr::fixed(delim)
  }
  if (too_many == "merge") {
    if (is.null(names)) {
      cli::cli_abort(
        'Must provide {.arg names} when {.code too_many = "merge"}.',
        call = error_call
      )
    }
    n <- length(names)
  } else {
    n <- Inf
  }

  pieces <- stringr::str_split(x, delim, n = n)

  lengths <- lengths(pieces)
  n_pieces <- ifelse(is.na(x), NA, lengths)

  names <- names %||% as.character(seq_len(int_max(lengths, 0)))
  p <- length(names)

  check_df_alignment(
    col,
    p,
    "pieces",
    n_pieces,
    too_few = too_few,
    too_many = too_many,
    advice_short = c(
      i = 'Use `too_few = "debug"` to diagnose the problem.',
      i = 'Use `too_few = "align_start"/"align_end"` to silence this message.'
    ),
    advice_long = c(
      i = 'Use `too_many = "debug"` to diagnose the problem.',
      i = 'Use `too_many = "drop"/"merge"` to silence this message.'
    ),
    call = error_call
  )

  out <- df_align(
    x = pieces,
    names = names,
    align_direction = if (too_few == "align_end") "end" else "start"
  )

  if (!cols_remove || too_few == "debug" || too_many == "debug") {
    out[[col]] <- x
  }

  if (too_few == "debug" || too_many == "debug") {
    separate_warn_debug(col, names_sep, c("ok", "pieces", "remainder"))
    sep_loc <- stringr::str_locate_all(x, delim)
    sep_last <- map(sep_loc, function(x) if (nrow(x) < p) NA else x[p, "start"])
    remainder <- stringr::str_sub(x, sep_last)
    remainder[is.na(remainder) & !is.na(x)] <- ""

    problem <- !is.na(x) &
      ((too_few == "debug" & n_pieces < p) |
        (too_many == "debug" & n_pieces > p))

    out[[debug_name(col, names_sep, "ok")]] <- !problem
    out[[debug_name(col, names_sep, "pieces")]] <- n_pieces
    out[[debug_name(col, names_sep, "remainder")]] <- remainder
  }

  out
}
R/separate-wider.R:183

separate_wider_delim untypeabletyped

unbound variable (line 142)
unbound: check_installed — a name the prelude does not declare
error detail
name: check_installed
gradual mode: typed
((data: any, cols: any, delim: any, ...: any, names: null?, names_sep: null?, names_repair: any?, too_few: any?, too_many: any?, cols_remove: any?) -> any)<>
timing: 0.183 s
source
separate_wider_delim <- function(
  data,
  cols,
  delim,
  ...,
  names = NULL,
  names_sep = NULL,
  names_repair = "check_unique",
  too_few = c("error", "debug", "align_start", "align_end"),
  too_many = c("error", "debug", "drop", "merge"),
  cols_remove = TRUE
) {
  check_installed("stringr")
  check_data_frame(data)
  check_required(cols)
  check_dots_empty()
  check_string(delim, allow_empty = FALSE)
  if (is.null(names) && is.null(names_sep)) {
    cli::cli_abort(
      "Must specify at least one of {.arg names} or {.arg names_sep}."
    )
  }
  check_character(names, allow_null = TRUE)
  if (is_named(names)) {
    cli::cli_abort("{.arg names} must be an unnamed character vector.")
  }
  too_few <- arg_match(too_few)
  too_many <- arg_match(too_many)
  check_bool(cols_remove)

  error_call %<~% current_env()

  map_unpack(
    data,
    {{ cols }},
    function(x, col) {
      str_separate_wider_delim(
        x,
        col,
        names = names,
        delim = delim,
        names_sep = names_sep,
        too_few = too_few,
        too_many = too_many,
        cols_remove = cols_remove,
        error_call = error_call
      )
    },
    names_sep = names_sep,
    names_repair = names_repair
  )
}
R/separate-wider.R:130

str_separate_wider_position untypeabletimeout

unbound variable (line 326)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: timeout
timing: 0.269 s
source
str_separate_wider_position <- function(
  x,
  col,
  widths,
  names_sep = NULL,
  too_few = "error",
  too_many = "error",
  cols_remove = TRUE,
  error_call = caller_env()
) {
  breaks <- cumsum(c(1L, unname(widths)))[-(length(widths) + 1L)]
  expected_width <- sum(widths)

  width <- stringr::str_length(x)
  check_df_alignment(
    col,
    expected_width,
    "characters",
    width,
    too_few = too_few,
    too_many = too_many,
    advice_short = c(
      i = 'Use `too_few = "debug"` to diagnose the problem.',
      i = 'Use `too_few = "align_start"` to silence this message.'
    ),
    advice_long = c(
      i = 'Use `too_many = "debug"` to diagnose the problem.',
      i = 'Use `too_many = "drop"` to silence this message.'
    ),
    call = error_call
  )

  skip <- names(widths) == ""
  from <- cbind(start = breaks[!skip], length = widths[!skip])
  names <- names(widths)[!skip]

  pieces <- stringr::str_sub_all(x, from)
  pieces <- map(pieces, function(x) x[x != ""])

  out <- df_align(
    x = pieces,
    names = names,
    align_direction = if (too_few == "end") "end" else "start"
  )

  if (!cols_remove || too_few == "debug" || too_many == "debug") {
    out[[col]] <- x
  }

  if (too_few == "debug" || too_many == "debug") {
    separate_warn_debug(col, names_sep, c("ok", "width", "remainder"))
    problem <- !is.na(x) &
      ((too_few == "debug" & width < expected_width) |
        (too_many == "debug" & width > expected_width))

    out[[debug_name(col, names_sep, "width")]] <- width
    out[[debug_name(col, names_sep, "remainder")]] <- stringr::str_sub(
      x,
      expected_width + 1,
      width
    )
    out[[debug_name(col, names_sep, "ok")]] <- !problem
  }

  out
}
R/separate-wider.R:318

separate_wider_position untypeabletyped

unbound variable (line 280)
unbound: check_installed — a name the prelude does not declare
error detail
name: check_installed
gradual mode: typed
((data: any, cols: any, widths: vec, ...: any, names_sep: any?, names_repair: any?, too_few: any?, too_many: any?, cols_remove: any?) -> any)<>
timing: 0.184 s
source
separate_wider_position <- function(
  data,
  cols,
  widths,
  ...,
  names_sep = NULL,
  names_repair = "check_unique",
  too_few = c("error", "debug", "align_start"),
  too_many = c("error", "debug", "drop"),
  cols_remove = TRUE
) {
  check_installed("stringr")
  check_data_frame(data)
  check_required(cols)
  check_required(widths)
  if (!is_integerish(widths) || !any(have_name(widths))) {
    cli::cli_abort("{.arg widths} must be a (partially) named integer vector.")
  }
  if (any(widths <= 0)) {
    cli::cli_abort("All values of {.arg widths} must be positive.")
  }

  check_dots_empty()
  too_few <- arg_match(too_few)
  too_many <- arg_match(too_many)
  check_bool(cols_remove)

  error_call %<~% current_env()

  map_unpack(
    data,
    {{ cols }},
    function(x, col) {
      str_separate_wider_position(
        x,
        col,
        widths = widths,
        names_sep = names_sep,
        too_few = too_few,
        too_many = too_many,
        cols_remove = cols_remove,
        error_call = error_call
      )
    },
    names_sep = names_sep,
    names_repair = names_repair
  )
}
R/separate-wider.R:269

str_separate_wider_regex untypeabletimeout

unbound variable (line 440)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: timeout
timing: 0.233 s
source
str_separate_wider_regex <- function(
  x,
  col,
  patterns,
  names_sep = NULL,
  too_few = "error",
  cols_remove = TRUE,
  error_call = caller_env()
) {
  has_name <- names2(patterns) != ""
  groups <- stringr::str_c("(", ifelse(has_name, "", "?:"), patterns, ")")
  full_match <- stringr::str_c(
    "^",
    stringr::str_flatten(groups, collapse = ""),
    "$"
  )

  match <- stringr::str_match(x, full_match)
  if (ncol(match) != sum(has_name) + 1L) {
    cli::cli_abort(
      c(
        "Invalid number of groups.",
        i = 'Did you use "()" instead of "(?:)" inside {.arg patterns}?'
      ),
      call = error_call
    )
  }

  matches <- match[, -1, drop = FALSE]
  out <- as_tibble(matches, .name_repair = "none")
  colnames(out) <- names2(patterns)[has_name]

  if (!cols_remove || too_few == "debug") {
    out[[col]] <- x
  }

  match_count <- ifelse(is.na(x), NA, length(patterns))
  remainder <- ifelse(is.na(x), NA, "")
  problems <- !is.na(x) & is.na(match[, 1])
  no_match <- which(problems)

  if (length(no_match) > 0) {
    if (too_few == "error") {
      cli::cli_abort(
        c(
          "Expected each value of {.var {col}} to match the pattern, the whole pattern, and nothing but the pattern.",
          "!" = "{length(no_match)} value{?s} {?has/have} problem{?s}.",
          i = 'Use {.code too_few = "debug"} to diagnose the problem.',
          i = 'Use {.code too_few = "align_start"} to silence this message.'
        ),
        call = error_call
      )
    }

    # Progressively relax the matches
    for (i in rev(seq_along(groups))) {
      partial <- paste0("^", paste(groups[1:i], collapse = ""), "(.*)$")
      match <- stringr::str_match(x[no_match], partial)
      has_match <- !is.na(match[, 1])
      match_idx <- no_match[has_match]
      if (length(match_idx) == 0) {
        next
      }

      matches <- as_tibble(
        match[has_match, -1, drop = FALSE],
        .name_repair = "none"
      )
      cols <- names2(patterns)[has_name][1:(ncol(matches) - 1)]
      out[match_idx, cols] <- matches[1:(ncol(matches) - 1)]
      remainder[match_idx] <- matches[[ncol(matches)]]
      match_count[match_idx] <- i

      no_match <- no_match[!has_match]
      if (length(no_match) == 0) {
        break
      }
    }

    if (length(no_match) > 0) {
      match_count[no_match] <- 0L
      remainder[no_match] <- x[no_match]
    }
  }

  if (too_few == "debug") {
    separate_warn_debug(col, names_sep, c("ok", "matches", "remainder"))
    out[debug_name(col, names_sep, "ok")] <- !problems
    out[debug_name(col, names_sep, "matches")] <- match_count
    out[debug_name(col, names_sep, "remainder")] <- remainder
  }

  out
}
R/separate-wider.R:433

separate_wider_regex untypeabletyped

unbound variable (line 400)
unbound: check_installed — a name the prelude does not declare
error detail
name: check_installed
gradual mode: typed
((data: any, cols: any, patterns: any, ...: any, names_sep: any?, names_repair: any?, too_few: any?, cols_remove: any?) -> any)<>
timing: 0.118 s
source
separate_wider_regex <- function(
  data,
  cols,
  patterns,
  ...,
  names_sep = NULL,
  names_repair = "check_unique",
  too_few = c("error", "debug", "align_start"),
  cols_remove = TRUE
) {
  check_installed("stringr")
  check_data_frame(data)
  check_required(cols)
  check_character(patterns)
  if (length(patterns) > 0 && all(!have_name(patterns))) {
    cli::cli_abort("{.arg patterns} must be a named character vector.")
  }
  check_dots_empty()
  check_string(names_sep, allow_null = TRUE)
  too_few <- arg_match(too_few)
  check_bool(cols_remove)

  error_call %<~% current_env()

  map_unpack(
    data,
    {{ cols }},
    function(x, col) {
      str_separate_wider_regex(
        x,
        col,
        patterns = patterns,
        names_sep = names_sep,
        too_few = too_few,
        cols_remove = cols_remove,
        error_call = error_call
      )
    },
    names_sep = names_sep,
    names_repair = names_repair
  )
}
R/separate-wider.R:390
R/seq.R

full_seq untypeabletyped

unbound variable (line 15)
unbound: UseMethod — a name the prelude does not declare
error detail
name: UseMethod
gradual mode: typed
((x: any, period: any, tol: any?) -> any)<>
timing: 0.009 s
source
full_seq <- function(x, period, tol = 1e-6) {
  UseMethod("full_seq")
}
R/seq.R:14

full_seq.numeric untypeable

unbound variable (line 20)
unbound: check_number_decimal — one of the package’s own names, itself untyped
error detail
name: check_number_decimal
timing: 0.071 s
source
full_seq.numeric <- function(x, period, tol = 1e-6) {
  check_number_decimal(period)
  check_number_decimal(tol, min = 0)

  rng <- range(x, na.rm = TRUE)
  if (
    any(
      ((x - rng[1]) %% period > tol) &
        (period - (x - rng[1]) %% period > tol)
    )
  ) {
    cli::cli_abort("{.arg x} is not a regular sequence.")
  }

  # in cases where the last element is within tolerance, pad it so that
  #   the output length is correct
  if (period - ((rng[2] - rng[1]) %% period) <= tol) {
    rng[2] <- rng[2] + tol
  }

  seq(rng[1], rng[2], by = period)
}
R/seq.R:19

restore untypeabletyped

unbound variable (line 53)
unbound: mostattributes<- — a name the prelude does not declare
error detail
name: mostattributes<-
gradual mode: typed
((old: <...> | <> with { }, new: any) | (old: <> with (list & ~{ }), new: any) -> any)<>
timing: 0.166 s
source
restore <- function(old, new) {
  mostattributes(new) <- attributes(old)
  new
}
R/seq.R:52

full_seq.Date untypeabletyped

unbound variable (line 44)
unbound: full_seq — one of the package’s own names, itself untyped
error detail
name: full_seq
gradual mode: typed
((x: vec, period: any, tol: any?) -> any)<>
timing: 0.044 s
source
full_seq.Date <- function(x, period, tol = 1e-6) {
  restore(x, full_seq(as.numeric(x), period, tol))
}
R/seq.R:43

full_seq.POSIXct untypeabletyped

unbound variable (line 49)
unbound: full_seq — one of the package’s own names, itself untyped
error detail
name: full_seq
gradual mode: typed
((x: vec, period: any, tol: any?) -> any)<>
timing: 0.044 s
source
full_seq.POSIXct <- function(x, period, tol = 1e-6) {
  restore(x, full_seq(as.numeric(x), period, tol))
}
R/seq.R:48
R/tidyr.R

<statement> typed

timing: 0.003 s
source
"_PACKAGE"
R/tidyr.R:13

<statement> untypeabletyped

unbound variable (line 15)
unbound: local_use_cli — a name the prelude does not declare
error detail
name: local_use_cli
gradual mode: typed
timing: 0.001 s
source
on_load(local_use_cli())
R/tidyr.R:15

the untypeabletyped

unbound variable (line 17)
unbound: new_environment — a name the prelude does not declare
error detail
name: new_environment
gradual mode: typed
any
timing: 0.001 s
source
the <- new_environment()
R/tidyr.R:17

<statement> untypeabletyped

unbound variable (line 19)
unbound: globalVariables — a name the prelude does not declare
error detail
name: globalVariables
gradual mode: typed
timing: 0.020 s
source
globalVariables(c(".", "name", "value"))
R/tidyr.R:19

<statement> untypeabletyped

unbound variable (line 23)
unbound: tibble::tribble — a name the prelude does not declare
error detail
name: tibble::tribble
gradual mode: typed
timing: 0.000 s
source
tibble::tribble
R/tidyr.R:23

<statement> untypeabletyped

unbound variable (line 27)
unbound: tibble::tibble — a name the prelude does not declare
error detail
name: tibble::tibble
gradual mode: typed
timing: 0.000 s
source
tibble::tibble
R/tidyr.R:27

<statement> untypeabletyped

unbound variable (line 31)
unbound: tibble::as_tibble — a name the prelude does not declare
error detail
name: tibble::as_tibble
gradual mode: typed
timing: 0.000 s
source
tibble::as_tibble
R/tidyr.R:31

<statement> untypeabletyped

unbound variable (line 36)
unbound: tidyselect::all_of — a name the prelude does not declare
error detail
name: tidyselect::all_of
gradual mode: typed
timing: 0.000 s
source
tidyselect::all_of
R/tidyr.R:36

<statement> untypeabletyped

unbound variable (line 39)
unbound: tidyselect::any_of — a name the prelude does not declare
error detail
name: tidyselect::any_of
gradual mode: typed
timing: 0.000 s
source
tidyselect::any_of
R/tidyr.R:39

<statement> untypeabletyped

unbound variable (line 42)
unbound: tidyselect::contains — a name the prelude does not declare
error detail
name: tidyselect::contains
gradual mode: typed
timing: 0.000 s
source
tidyselect::contains
R/tidyr.R:42

<statement> untypeabletyped

unbound variable (line 45)
unbound: tidyselect::ends_with — a name the prelude does not declare
error detail
name: tidyselect::ends_with
gradual mode: typed
timing: 0.000 s
source
tidyselect::ends_with
R/tidyr.R:45

<statement> untypeabletyped

unbound variable (line 48)
unbound: tidyselect::everything — a name the prelude does not declare
error detail
name: tidyselect::everything
gradual mode: typed
timing: 0.000 s
source
tidyselect::everything
R/tidyr.R:48

<statement> untypeabletyped

unbound variable (line 51)
unbound: tidyselect::last_col — a name the prelude does not declare
error detail
name: tidyselect::last_col
gradual mode: typed
timing: 0.000 s
source
tidyselect::last_col
R/tidyr.R:51

<statement> untypeabletyped

unbound variable (line 54)
unbound: tidyselect::matches — a name the prelude does not declare
error detail
name: tidyselect::matches
gradual mode: typed
timing: 0.000 s
source
tidyselect::matches
R/tidyr.R:54

<statement> untypeabletyped

unbound variable (line 57)
unbound: tidyselect::num_range — a name the prelude does not declare
error detail
name: tidyselect::num_range
gradual mode: typed
timing: 0.000 s
source
tidyselect::num_range
R/tidyr.R:57

<statement> untypeabletyped

unbound variable (line 60)
unbound: tidyselect::one_of — a name the prelude does not declare
error detail
name: tidyselect::one_of
gradual mode: typed
timing: 0.000 s
source
tidyselect::one_of
R/tidyr.R:60

<statement> untypeabletyped

unbound variable (line 63)
unbound: tidyselect::starts_with — a name the prelude does not declare
error detail
name: tidyselect::starts_with
gradual mode: typed
timing: 0.000 s
source
tidyselect::starts_with
R/tidyr.R:63
R/uncount.R

uncount untypeabletyped

unbound variable (line 26)
unbound: check_dots_used — a name the prelude does not declare
error detail
name: check_dots_used
gradual mode: typed
((data: any, weights: any, ...: any, .remove: any?, .id: any?) -> any)<>
timing: 0.013 s
source
uncount <- function(data, weights, ..., .remove = TRUE, .id = NULL) {
  check_dots_used()
  UseMethod("uncount")
}
R/uncount.R:25

uncount.data.frame untypeabletyped

unbound variable (line 32)
unbound: check_bool — one of the package’s own names, itself untyped
error detail
name: check_bool
gradual mode: typed
((data: any, weights: any, ...: any, .remove: any?, .id: null?) -> any)<>
timing: 0.050 s
source
uncount.data.frame <- function(data, weights, ..., .remove = TRUE, .id = NULL) {
  check_bool(.remove)
  check_name(.id, allow_null = TRUE)

  weights_quo <- enquo(weights)
  w <- dplyr::pull(dplyr::mutate(data, `_weight` = !!weights_quo))

  out <- vec_rep_each(
    data,
    w,
    error_call = current_env(),
    times_arg = "weights"
  )

  # NOTE it was decided to also remove grouping variables as there is no clear
  # best answer. See https://github.com/tidyverse/tidyr/pull/1070
  if (.remove && quo_is_symbol(weights_quo)) {
    out[[as_string(get_expr(weights_quo))]] <- NULL
  }

  if (!is.null(.id)) {
    out[[.id]] <- sequence(w)
  }

  reconstruct_tibble(data, out)
}
R/uncount.R:31
R/unnest-longer.R

collect_indices_info untypeabletyped

unbound variable (line 264)
unbound: is_false — a name the prelude does not declare
error detail
name: is_false
gradual mode: typed
((col: any, sizes: 0, indices_include: null, keep_empty: any) | (col: any, sizes: 0, indices_include: ~null, keep_empty: any) | (col: any, sizes: ~0, indices_include: null, keep_empty: any) | (col: any, sizes: ~0, indices_include: ~null, keep_empty: any) -> { indices: any, indices_include: tt<>, index_ptype: CHR<> | INT<> }<> | { indices: null, indices_include: ff<>, index_ptype: null }<>)<>
timing: 0.074 s
source
collect_indices_info <- function(col, sizes, indices_include, keep_empty) {
  out <- list(
    indices_include = FALSE,
    indices = NULL,
    index_ptype = NULL
  )

  if (is_false(indices_include)) {
    return(out)
  }

  indices <- map(col, vec_names)
  unnamed <- vec_detect_missing(indices)
  all_unnamed <- all(unnamed)

  if (is.null(indices_include) && all_unnamed) {
    # Same as `indices_include = FALSE`
    return(out)
  }

  if (all_unnamed) {
    # Indices are requested, but none of the elements are named.
    # Generate integer column of sequential indices.
    indices <- map(sizes, seq_len)
    index_ptype <- integer()
  } else {
    # Indices are requested, and some elements are named.
    # For any unnamed elements, generate `NA` indices.
    indices[unnamed] <- map(sizes[unnamed], vec_rep, x = "")
    index_ptype <- character()
  }

  if (keep_empty) {
    empty <- sizes == 0L

    if (any(empty)) {
      # `NULL` or typed empty elements get an `NA` index of the right type
      index_empty <- vec_init(index_ptype)
      indices[empty] <- list(index_empty)
    }
  }

  out$indices_include <- TRUE
  out$indices <- indices
  out$index_ptype <- index_ptype

  out
}
R/unnest-longer.R:257

new_long_frame untypeabletyped

unbound variable (line 249)
unbound: new_data_frame — a name the prelude does not declare
error detail
name: new_data_frame
gradual mode: typed
((x: any, size: any, name: vec | null) -> any)<>
timing: 0.035 s
source
new_long_frame <- function(x, size, name) {
  out <- list(x)
  names(out) <- name
  new_data_frame(out, n = size)
}
R/unnest-longer.R:246

new_long_indexed_frame untypeabletyped

unbound variable (line 254)
unbound: new_data_frame — a name the prelude does not declare
error detail
name: new_data_frame
gradual mode: typed
((x: any, index: any, size: any, indices_to: vec | null, values_to: vec | null) -> any)<>
timing: 0.279 s
source
new_long_indexed_frame <- function(x, index, size, indices_to, values_to) {
  out <- list(index, x)
  names(out) <- c(indices_to, values_to)
  new_data_frame(out, n = size)
}
R/unnest-longer.R:251

col_to_long untypeable

unbound variable (line 162)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
timing: 0.397 s
source
col_to_long <- function(
  col,
  name,
  values_to,
  indices_to,
  indices_include,
  keep_empty,
  error_call = caller_env()
) {
  if (vec_is_list(col)) {
    ptype <- list_of_ptype(col)
  } else {
    ptype <- vec_ptype(col)
    col <- vec_chop(col)
  }

  # Avoid expensive dispatch from `[[.list_of`, and allow for `[[<-`.
  # We've already captured the `ptype`.
  col <- tidyr_new_list(col)

  if (!list_all_vectors2(col)) {
    cli::cli_abort(
      "List-column {.var {name}} must contain only vectors or `NULL`.",
      call = error_call
    )
  }

  sizes <- list_sizes(col)

  # Collect index info before replacing `NULL`s so `keep_empty` works correctly
  info <- collect_indices_info(col, sizes, indices_include, keep_empty)
  indices_include <- info$indices_include
  indices <- info$indices
  index_ptype <- info$index_ptype

  size_null <- as.integer(keep_empty)

  info <- list_replace_null(col, sizes, ptype = ptype, size = size_null)
  col <- info$x
  sizes <- info$sizes

  if (keep_empty) {
    info <- list_replace_empty_typed(col, sizes, ptype = ptype, size = 1L)
    col <- info$x
    sizes <- info$sizes
  }

  if (is.null(ptype)) {
    # Initialize `ptype` to generate a `ptype` version of the output data frame.
    # Important in the size 0 input case.
    ptype <- unspecified()
  }

  if (indices_include) {
    ptype <- new_long_indexed_frame(
      x = ptype,
      index = index_ptype,
      size = 0L,
      indices_to = indices_to,
      values_to = values_to
    )
    col <- pmap(
      list(col, indices, sizes),
      function(elt, index, size) {
        new_long_indexed_frame(
          x = elt,
          index = index,
          size = size,
          indices_to = indices_to,
          values_to = values_to
        )
      }
    )
  } else {
    name <- values_to
    ptype <- new_long_frame(ptype, 0L, name)
    col <- map2(
      col,
      sizes,
      function(elt, size) new_long_frame(elt, size, name)
    )
  }

  ptype <- vec_ptype_common(ptype, !!!col)
  col <- vec_cast_common(!!!col, .to = ptype)

  col <- new_list_of(col, ptype = ptype)

  col
}
R/unnest-longer.R:155

glue_col_names untypeabletyped

unbound variable (line 308)
unbound: glue::glue_data — a name the prelude does not declare
error detail
name: glue::glue_data
gradual mode: typed
((string: any, col_names: any) -> any)<>
timing: 0.010 s
source
glue_col_names <- function(string, col_names) {
  data <- list(col = col_names)
  out <- glue::glue_data(data, string, .envir = NULL)
  out <- as.character(out)
  out
}
R/unnest-longer.R:306

unnest_longer untypeable

unbound variable (line 85)
unbound: check_data_frame — one of the package’s own names, itself untyped
error detail
name: check_data_frame
timing: 0.687 s
source
unnest_longer <- function(
  data,
  col,
  values_to = NULL,
  indices_to = NULL,
  indices_include = NULL,
  keep_empty = FALSE,
  names_repair = "check_unique",
  simplify = TRUE,
  ptype = NULL,
  transform = NULL
) {
  check_data_frame(data)
  check_required(col)
  check_name(values_to, allow_null = TRUE)
  check_name(indices_to, allow_null = TRUE)
  check_bool(indices_include, allow_null = TRUE)
  check_bool(keep_empty)

  error_call <- current_env()

  cols <- tidyselect::eval_select(enquo(col), data, allow_rename = FALSE)
  col_names <- names(cols)
  n_col_names <- length(col_names)

  values_to <- values_to %||% "{col}"

  if (is.null(indices_to)) {
    indices_to <- vec_paste0(values_to, "_id")
  } else {
    if (is_false(indices_include)) {
      cli::cli_abort(
        "Can't use {.code indices_include = FALSE} when {.arg indices_to} is supplied."
      )
    }
    indices_include <- TRUE
  }

  values_to <- glue_col_names(values_to, col_names)
  values_to <- vec_recycle(values_to, size = n_col_names)

  indices_to <- glue_col_names(indices_to, col_names)
  indices_to <- vec_recycle(indices_to, size = n_col_names)

  for (i in seq_along(cols)) {
    col <- cols[[i]]
    col_name <- col_names[[i]]
    col_values_to <- values_to[[i]]
    col_indices_to <- indices_to[[i]]

    data[[col]] <- col_to_long(
      col = data[[col]],
      name = col_name,
      values_to = col_values_to,
      indices_to = col_indices_to,
      indices_include = indices_include,
      keep_empty = keep_empty
    )
  }

  data <- unchop(data, all_of(col_names), error_call = error_call)

  for (i in seq_along(cols)) {
    col <- cols[[i]]

    data[[col]] <- df_simplify(
      x = data[[col]],
      ptype = ptype,
      transform = transform,
      simplify = simplify
    )
  }

  unpack(
    data = data,
    cols = all_of(col_names),
    names_repair = names_repair,
    error_call = error_call
  )
}
R/unnest-longer.R:73
R/unnest-wider.R

stop_use_names_sep untypeabletyped

unbound variable (line 269)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
gradual mode: typed
((error_call: any?) -> any)<>
timing: 0.006 s
source
stop_use_names_sep <- function(error_call = caller_env()) {
  message <- c(
    "Can't unnest elements with missing names.",
    i = "Supply {.arg names_sep} to generate automatic names."
  )
  cli::cli_abort(message, call = error_call)
}
R/unnest-wider.R:269

elt_to_wide untypeable

unbound variable (line 216)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
timing: 0.153 s
source
elt_to_wide <- function(x, name, strict, names_sep, error_call = caller_env()) {
  if (is.null(x)) {
    x <- list()
  }

  if (!vec_is(x)) {
    cli::cli_abort(
      "List-column must only contain vectors.",
      call = error_call
    )
  }

  if (is.data.frame(x)) {
    # Extremely special case for data.frames,
    # which we want to treat like lists where we know the type of each element
    x <- tidyr_new_list(x)
    x <- map(x, list_of)
    names <- names2(x)
    x <- set_names(x, NULL)
  } else {
    if (!strict && vec_is_list(x)) {
      empty <- list_sizes(x) == 0L
      if (any(empty)) {
        # Can't use vec_assign(), see https://github.com/r-lib/vctrs/issues/1424
        x[empty] <- list(NULL)
      }
    }

    names <- vec_names2(x)
    x <- vec_set_names(x, NULL)
    x <- vec_chop(x)
  }

  empty <- names == ""
  any_empty <- any(empty)

  if (is.null(names_sep)) {
    if (any_empty) {
      stop_use_names_sep(error_call = error_call)
    }
  } else {
    if (any_empty) {
      names[empty] <- as.character(which(empty))
    }
    names <- apply_names_sep(name, names, names_sep)
  }

  x <- set_names(x, names)
  x <- new_data_frame(x, n = 1L)

  x
}
R/unnest-wider.R:216

col_to_wide untypeable

unbound variable (line 139)
unbound: caller_env — a name the prelude does not declare
error detail
name: caller_env
timing: 0.191 s
source
col_to_wide <- function(
  col,
  name,
  strict,
  names_sep,
  error_call = caller_env()
) {
  if (!vec_is_list(col)) {
    ptype <- vec_ptype(col)
    col <- vec_chop(col)
    col <- new_list_of(col, ptype = ptype)
  }

  # If we don't have a list_of, then a `NULL` `col_ptype` will get converted to
  # a 1 row, 0 col tibble for `elt_ptype`
  col_ptype <- list_of_ptype(col)
  elt_ptype <- elt_to_wide(
    col_ptype,
    name = name,
    strict = strict,
    names_sep = names_sep,
    error_call = error_call
  )
  elt_ptype <- vec_ptype(elt_ptype)

  # Avoid expensive dispatch from `[[.list_of`
  out <- tidyr_new_list(col)

  out <- with_indexed_errors(
    map(
      out,
      function(x) {
        elt_to_wide(
          x = x,
          name = name,
          strict = strict,
          names_sep = names_sep,
          error_call = NULL
        )
      }
    ),
    message = function(cnd) {
      c(
        i = cli::format_inline("In column: {.code {name}}."),
        i = cli::format_inline("In row: {cnd$location}.")
      )
    },
    .error_call = error_call
  )

  # In the sole case of a list_of<data_frame>, we can be sure that the
  # elements of `out` will all be of the same type. Otherwise,
  # - If `col` isn't a list-of, we don't know the element type.
  # - If `col` is a list-of but not one with a data frame ptype, then we
  #   don't actually know if all elements have the same ptype, because the
  #   number of resulting columns per element depends on that element's size.
  has_identical_elements <- is_list_of(col) && is.data.frame(col_ptype)

  if (has_identical_elements) {
    ptype <- elt_ptype
  } else {
    ptype <- vec_ptype_common(elt_ptype, !!!out)
    out <- vec_cast_common(!!!out, .to = ptype)
  }

  out <- new_list_of(out, ptype = ptype)

  out
}
R/unnest-wider.R:134

unnest_wider untypeabletyped

unbound variable (line 90)
unbound: check_data_frame — one of the package’s own names, itself untyped
error detail
name: check_data_frame
gradual mode: typed
((data: any, col: any, names_sep: any?, simplify: any?, strict: any?, names_repair: any?, ptype: any?, transform: any?) -> any)<>
timing: 0.337 s
source
unnest_wider <- function(
  data,
  col,
  names_sep = NULL,
  simplify = TRUE,
  strict = FALSE,
  names_repair = "check_unique",
  ptype = NULL,
  transform = NULL
) {
  check_data_frame(data)
  check_required(col)
  check_string(names_sep, allow_null = TRUE)
  check_bool(strict)

  error_call <- current_env()

  cols <- tidyselect::eval_select(enquo(col), data, allow_rename = FALSE)
  col_names <- names(cols)

  for (i in seq_along(cols)) {
    col <- cols[[i]]
    col_name <- col_names[[i]]

    data[[col]] <- col_to_wide(
      col = data[[col]],
      name = col_name,
      strict = strict,
      names_sep = names_sep
    )
  }

  data <- unchop(data, all_of(col_names), error_call = error_call)

  for (i in seq_along(cols)) {
    col <- cols[[i]]

    data[[col]] <- df_simplify(
      x = data[[col]],
      ptype = ptype,
      transform = transform,
      simplify = simplify
    )
  }

  unpack(
    data = data,
    cols = all_of(col_names),
    names_repair = names_repair,
    error_call = error_call
  )
}
R/unnest-wider.R:80
R/unnest-auto.R

guess_dir untypeabletyped

unbound variable (line 37)
unbound: map — a name the prelude does not declare
error detail
name: map
gradual mode: typed
((x: any, col: any) -> "longer"<> | "longer_idx"<> | "wider"<>)<>
timing: 0.076 s
source
guess_dir <- function(x, col) {
  names <- map(x, names)
  is_null <- unique(map_lgl(names, is.null))

  if (identical(is_null, TRUE)) {
    # all unnamed
    code <- glue::glue("unnest_longer({col}, indices_include = FALSE)")
    reason <- "no element has names"
    out <- "longer"
  } else if (identical(is_null, FALSE)) {
    # all named
    common <- reduce(names, intersect)
    n_common <- length(common)
    if (n_common == 0) {
      code <- glue::glue("unnest_longer({col}, indices_include = TRUE)")
      reason <- "elements are named, but have no names in common"
      out <- "longer_idx"
    } else {
      code <- glue::glue("unnest_wider({col})")
      reason <- glue::glue("elements have {n_common} names in common")
      out <- "wider"
    }
  } else {
    code <- glue::glue("unnest_longer({col}, indices_include = FALSE)")
    reason <- "mix of named and unnamed elements"
    out <- "longer"
  }

  message(glue::glue("Using `{code}`; {reason}"))
  out
}
R/unnest-auto.R:36

unnest_auto untypeabletyped

unbound variable (line 22)
unbound: check_required — a name the prelude does not declare
error detail
name: check_required
gradual mode: typed
((data: any, col: any) -> any)<>
timing: 0.009 s
source
unnest_auto <- function(data, col) {
  check_required(col)
  col <- tidyselect::vars_pull(tbl_vars(data), {{ col }})

  x <- data[[col]]
  dir <- guess_dir(x, col)

  switch(
    dir,
    longer = unnest_longer(data, {{ col }}, indices_include = FALSE),
    longer_idx = unnest_longer(data, {{ col }}, indices_include = TRUE),
    wider = unnest_wider(data, {{ col }}, names_repair = "unique")
  )
}
R/unnest-auto.R:21
R/unnest.R

unnest skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.045 s
source
unnest <- function(
  data,
  cols,
  ...,
  keep_empty = FALSE,
  ptype = NULL,
  names_sep = NULL,
  names_repair = "check_unique",
  .drop = deprecated(),
  .id = deprecated(),
  .sep = deprecated(),
  .preserve = deprecated()
) {
  deprecated <- FALSE
  if (!missing(.preserve)) {
    lifecycle::deprecate_warn(
      "1.0.0",
      "unnest(.preserve = )",
      details = "All list-columns are now preserved",
      always = TRUE
    )
    deprecated <- TRUE
    .preserve <- tidyselect::vars_select(tbl_vars(data), !!enquo(.preserve))
  } else {
    .preserve <- NULL
  }

  if (missing(cols) && missing(...)) {
    list_cols <- names(data)[map_lgl(data, is_list)]
    cols <- expr(c(!!!syms(setdiff(list_cols, .preserve))))
    cli::cli_warn(c(
      "`cols` is now required when using `unnest()`.",
      i = "Please use `cols = {expr_text(cols)}`."
    ))
    deprecated <- TRUE
  }

  if (missing(...)) {
    cols <- enquo(cols)
  } else {
    dots <- enquos(cols, ..., .named = TRUE, .ignore_empty = "all")
    data <- dplyr::mutate(data, !!!dots)

    cols <- expr(c(!!!syms(names(dots))))
    unnest_call <- expr(unnest(!!cols))
    cli::cli_warn(c(
      "`unnest()` has a new interface. See `?unnest` for details.",
      i = "Try `df |> {expr_text(unnest_call)}`, with `mutate()` if needed."
    ))
    deprecated <- TRUE
  }

  if (!is_missing(.drop)) {
    lifecycle::deprecate_warn(
      "1.0.0",
      "unnest(.drop = )",
      details = "All list-columns are now preserved.",
      always = TRUE
    )
    deprecated <- TRUE
  }

  if (!is_missing(.id)) {
    lifecycle::deprecate_warn(
      "1.0.0",
      "unnest(.id = )",
      details = "Manually create column of names instead.",
      always = TRUE
    )
    deprecated <- TRUE
    first_col <- tidyselect::vars_select(tbl_vars(data), !!cols)[[1]]
    data[[.id]] <- names(data[[first_col]])
  }

  if (!is_missing(.sep)) {
    lifecycle::deprecate_warn(
      "1.0.0",
      "unnest(.sep = )",
      details = glue("Use `names_sep = '{.sep}'` instead.")
    )
    deprecated <- TRUE
    names_sep <- .sep
  }

  if (deprecated) {
    return(unnest(
      data,
      cols = !!cols,
      names_sep = names_sep,
      keep_empty = keep_empty,
      ptype = ptype,
      names_repair = tidyr_legacy
    ))
  }

  UseMethod("unnest")
}
R/unnest.R:73

unnest.data.frame untypeabletyped

unbound variable (line 185)
unbound: current_env — a name the prelude does not declare
error detail
name: current_env
gradual mode: typed
((data: any, cols: any, ...: any, keep_empty: any?, ptype: any?, names_sep: any?, names_repair: any?, .drop: any?, .id: any?, .sep: any?, .preserve: any?) -> any)<>
timing: 0.047 s
source
unnest.data.frame <- function(
  data,
  cols,
  ...,
  keep_empty = FALSE,
  ptype = NULL,
  names_sep = NULL,
  names_repair = "check_unique",
  .drop = "DEPRECATED",
  .id = "DEPRECATED",
  .sep = "DEPRECATED",
  .preserve = "DEPRECATED"
) {
  error_call <- current_env()

  cols <- tidyselect::eval_select(
    expr = enquo(cols),
    data = data,
    allow_rename = FALSE
  )
  cols <- unname(cols)

  data <- unchop(
    data = data,
    cols = all_of(cols),
    keep_empty = keep_empty,
    ptype = ptype,
    error_call = error_call
  )

  unpack(
    data = data,
    cols = all_of(cols),
    names_sep = names_sep,
    names_repair = names_repair,
    error_call = error_call
  )
}
R/unnest.R:172

unnest.rowwise_df untypeabletyped

unbound variable (line 222)
unbound: as_tibble — a name the prelude does not declare
error detail
name: as_tibble
gradual mode: typed
((data: any, cols: any, ...: any, keep_empty: any?, ptype: any?, names_sep: any?, names_repair: any?) -> any)<>
timing: 0.023 s
source
unnest.rowwise_df <- function(
  data,
  cols,
  ...,
  keep_empty = FALSE,
  ptype = NULL,
  names_sep = NULL,
  names_repair = "check_unique"
) {
  out <- unnest.data.frame(
    as_tibble(data),
    {{ cols }},
    keep_empty = keep_empty,
    ptype = ptype,
    names_sep = names_sep,
    names_repair = names_repair
  )

  out <- dplyr::grouped_df(out, dplyr::group_vars(data))

  out
}
R/unnest.R:212
R/zzz.R

.onLoad untypeabletyped

unbound variable (line 2)
unbound: run_on_load — a name the prelude does not declare
error detail
name: run_on_load
gradual mode: typed
((libname: any, pkgname: any) -> any)<>
timing: 0.003 s
source
.onLoad <- function(libname, pkgname) {
  run_on_load()
}
R/zzz.R:1