diff --git a/R/compat-dplyr.R b/R/compat-dplyr.R index d39e7bf6c..7e81e656b 100644 --- a/R/compat-dplyr.R +++ b/R/compat-dplyr.R @@ -26,7 +26,7 @@ arrange_pos_id <- function(data) { bind_rows <- function(x, y = NULL, ...) { if (is.null(x) && is.null(y)) { - return(new_tibble(list(), nrow = 0)) + return(new_tibble(list())) } if (is.null(x)) { if (inherits(y, "data.frame")) { @@ -62,7 +62,7 @@ left_join <- function(x, y, by) { res <- merge(x, y, by.x = by_x, by.y = by_y, all.x = TRUE, sort = FALSE) %>% arrange_pos_id() - res <- new_tibble(res, nrow = nrow(res)) + res <- new_tibble(res) # dplyr::left_join set unknown list columns to NULL, merge sets them # to NA if (exists("child", res) && anyNA(res$child)) { diff --git a/R/compat-tidyr.R b/R/compat-tidyr.R index a1b8543bc..d8fed83a0 100644 --- a/R/compat-tidyr.R +++ b/R/compat-tidyr.R @@ -6,5 +6,5 @@ nest_ <- function(data, key_col, nest_cols = character()) { res <- list() res[[key_column]] <- key_levels res[[key_col]] <- split(data[, nest_cols], key_factor) - new_tibble(res, nrow = length(key_levels)) + new_tibble(res) } diff --git a/R/nest.R b/R/nest.R index aed8c03e9..f43cdb2e9 100644 --- a/R/nest.R +++ b/R/nest.R @@ -253,8 +253,7 @@ add_terminal_token_after <- function(pd_flat) { list( pos_id = terminals$pos_id, token_after = lead(terminals$token, default = "") - ), - nrow = nrow(terminals) + ) ) left_join(pd_flat, rhs, by = "pos_id") @@ -271,8 +270,7 @@ add_terminal_token_before <- function(pd_flat) { list( id = terminals$id, token_before = lag(terminals$token, default = "") - ), - nrow = nrow(terminals) + ) ) left_join(pd_flat, rhs, by = "id") diff --git a/R/token-create.R b/R/token-create.R index 54482cc5d..d1b53b648 100644 --- a/R/token-create.R +++ b/R/token-create.R @@ -59,8 +59,7 @@ create_tokens <- function(tokens, stylerignore = stylerignore, block = block, is_cached = is_cached - ), - nrow = len_text + ) ) } @@ -78,7 +77,7 @@ create_tokens <- function(tokens, #' create one. The validation is done with [validate_new_pos_ids()] #' @family token creators #' @keywords internal -create_pos_ids <- function(pd, pos, by = 0.1, after = FALSE, n = 1) { +create_pos_ids <- function(pd, pos, by = 0.1, after = FALSE, n = 1L) { direction <- ifelse(after, 1L, -1L) first <- find_start_pos_id(pd, pos, by, direction, after) new_ids <- seq(first, diff --git a/R/transform-files.R b/R/transform-files.R index 6a71bc982..225866c45 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -30,7 +30,7 @@ transform_files <- function(files, ) communicate_summary(changed, max_char) communicate_warning(changed, transformers) - new_tibble(list(file = files, changed = changed), nrow = len_files) + new_tibble(list(file = files, changed = changed)) } #' Transform a file and output a customized message diff --git a/man/create_pos_ids.Rd b/man/create_pos_ids.Rd index fc0b3393d..4498e19f0 100644 --- a/man/create_pos_ids.Rd +++ b/man/create_pos_ids.Rd @@ -4,7 +4,7 @@ \alias{create_pos_ids} \title{Create valid pos_ids if possible} \usage{ -create_pos_ids(pd, pos, by = 0.1, after = FALSE, n = 1) +create_pos_ids(pd, pos, by = 0.1, after = FALSE, n = 1L) } \arguments{ \item{pd}{A parse table.}