Skip to content

Provide rbind() and cbind() methods #909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export(rowid_to_column)
export(rownames_to_column)
export(set_tidy_names)
export(size_sum)
export(tbl_cbind)
export(tbl_rbind)
export(tbl_sum)
export(tibble)
export(tibble_)
Expand All @@ -69,6 +71,8 @@ export(type_sum)
export(validate_tibble)
export(view)
exportClasses(tbl_df)
if (getRversion() >= "4.0.0") S3method(cbind, tbl_df)
if (getRversion() >= "4.0.0") S3method(rbind, tbl_df)
import(ellipsis)
import(rlang)
importFrom(lifecycle,deprecate_soft)
Expand Down Expand Up @@ -97,6 +101,7 @@ importFrom(vctrs,vec_as_names_legacy)
importFrom(vctrs,vec_as_subscript2)
importFrom(vctrs,vec_assign)
importFrom(vctrs,vec_c)
importFrom(vctrs,vec_cbind)
importFrom(vctrs,vec_is)
importFrom(vctrs,vec_names)
importFrom(vctrs,vec_names2)
Expand Down
20 changes: 20 additions & 0 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,24 @@ tibble_options <- list2(
view_max = make_option_impl(
getOption("tibble.view_max", default = 1000L)
),
#' - `rbind_trace`: Print diagnostic information for [rbind()] calls.
#' Default: `FALSE`.
rbind_trace = make_option_impl(
getOption("tibble.rbind_trace", default = FALSE)
),
#' - `cbind_trace`: Print diagnostic information for [cbind()] calls.
#' Default: `FALSE`.
cbind_trace = make_option_impl(
getOption("tibble.cbind_trace", default = FALSE)
),
#' - `rbind_base`: Forware [rbind()] calls to base.
#' Default: `FALSE`.
rbind_base = make_option_impl(
getOption("tibble.rbind_base", default = FALSE)
),
#' - `cbind_base`: Forware [cbind()] calls to base.
#' Default: `FALSE`.
cbind_base = make_option_impl(
getOption("tibble.cbind_base", default = FALSE)
),
)
63 changes: 63 additions & 0 deletions R/tbl_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,69 @@ cnd_names_non_na <- function(name) {
}
}

#' Binding rows and columns
#'
#' @description
#' `r lifecycle::badge("experimental")`
#'
#' In tibble 4.0.0, the [rbind()] and [cbind()] methods
#' will become stricter.
#' These functions are designed to help the transition to those stricter
#' versions.
#' Replace calls to `rbind()` and `cbind()` with `tbl_rbind()` and `tbl_cbind()`,
#' respectively, to preview how your code will behave after the upgrade.
#' Set the `tibble.rbind_trace` or `tibble.cbind_trace` options to `TRUE`
#' to enable diagnostic information.
#' @export
tbl_rbind <- function(...) {
# deparse.level is part of the interface of the rbind generic
# but not passed along for data frame methods

if (tibble_options$rbind_trace()) {
writeLines("rbind()")
print(list(...))
writeLines("rbind() results")
print(base:::rbind.data.frame(...))
try(print(vec_rbind(!!!list(...))))
writeLines("rbind() end")
}

vec_rbind(!!!list(...))
}

#' @rdname tbl_rbind
#' @export
tbl_cbind <- function(...) {
if (tibble_options$cbind_trace()) {
writeLines("cbind()")
print(list(...))
writeLines("cbind() results")
print(base:::cbind.data.frame(...))
try(print(vec_cbind(!!!list(...))))
writeLines("cbind() end")
}

vec_cbind(!!!list(...))
}

#' @rawNamespace if (getRversion() >= "4.0.0") S3method(rbind, tbl_df)
if (getRversion() >= "4.0.0") rbind.tbl_df <- function(...) {
if (tibble_options$rbind_base()) {
NextMethod("rbind")
} else {
tbl_rbind(...)
}
}

#' @rawNamespace if (getRversion() >= "4.0.0") S3method(cbind, tbl_df)
if (getRversion() >= "4.0.0") cbind.tbl_df <- function(...) {
if (tibble_options$cbind_base()) {
NextMethod("cbind")
} else {
tbl_cbind(...)
}
}

# Errors ------------------------------------------------------------------

error_names_must_be_non_null <- function() {
Expand Down
1 change: 1 addition & 0 deletions R/tibble-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' @importFrom lifecycle deprecate_soft deprecate_warn expect_deprecated
#' @importFrom vctrs vec_as_location vec_as_location2 vec_as_names vec_as_names_legacy vec_c
#' @importFrom vctrs vec_is vec_rbind vec_recycle vec_size vec_slice vec_assign
#' @importFrom vctrs vec_cbind
#' @importFrom vctrs unspecified vec_as_subscript2 num_as_location vec_ptype_abbr
#' @importFrom vctrs vec_names vec_names2 vec_set_names
#' @importFrom vctrs new_rcrd
Expand Down
23 changes: 23 additions & 0 deletions man/tbl_rbind.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/tibble-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/tibble_options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 51 additions & 85 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,54 @@
# Platform

|field |value |
|:--------|:----------------------------|
|version |R version 3.6.2 (2019-12-12) |
|os |Debian GNU/Linux 10 (buster) |
|system |x86_64, linux-gnu |
|ui |RStudio |
|language |(EN) |
|collate |en_US.UTF-8 |
|ctype |en_US.UTF-8 |
|tz |Etc/UTC |
|date |2020-03-29 |

# Dependencies

|package |old |new |Δ |
|:-------|:-----|:------------|:--|
|tibble |2.1.3 |2.99.99.9015 |* |

# Revdeps

## Failed to check (22)

|package |version |error |warning |note |
|:----------------|:-------|:-----|:-------|:----|
|apaTables |? | | | |
|broom |? | | | |
|broom.mixed |? | | | |
|CNVScope |? | | | |
|codebook |? | | | |
|codemetar |0.1.8 |1 | |1 |
|embed |? | | | |
|ggstatsplot |? | | | |
|healthcareai |2.4.0 |1 | | |
|holodeck |? | | | |
|mcp |? | | | |
|obfuscatoR |? | | | |
|oolong |0.3.4 |1 | | |
|statsExpressions |? | | | |
|STRMPS |? | | | |
|TestDimorph |? | | | |
|tidybayes |? | | | |
|tidyBF |? | | | |
|tidycomm |? | | | |
|tidymodels |? | | | |
|ToxicoGx |? | | | |
|trialr |0.1.3 |1 | | |

## New problems (34)

|package |version |error |warning |note |
|:------------------------------------------------|:-------|:------|:-------|:----|
|[autocogs](problems.md#autocogs) |0.1.2 |2 |__+1__ |1 |
|[basket](problems.md#basket) |0.10.1 |__+1__ | | |
|[beadplexr](problems.md#beadplexr) |0.3.0 |__+1__ | | |
|[casen](problems.md#casen) |0.1.3 |__+1__ | |2 |
|[CGPfunctions](problems.md#cgpfunctions) |0.5.9 |__+1__ | | |
|[concurve](problems.md#concurve) |2.3.0 |__+1__ | |1 |
|[convergEU](problems.md#convergeu) |0.4.1 |__+2__ | |2 |
|[cutpointr](problems.md#cutpointr) |1.0.1 |__+1__ | | |
|[cvms](problems.md#cvms) |0.3.2 |__+1__ | | |
|[epikit](problems.md#epikit) |0.1.0 |__+1__ | |1 |
|[evaluator](problems.md#evaluator) |0.4.1 |__+2__ | | |
|[forestmangr](problems.md#forestmangr) |0.9.1 |__+1__ | | |
|[gratia](problems.md#gratia) |0.3.0 |__+1__ | | |
|[heemod](problems.md#heemod) |0.11.0 |__+2__ | |1 |
|[INDperform](problems.md#indperform) |0.2.2 |__+2__ | |1 |
|[janitor](problems.md#janitor) |1.2.1 |__+2__ | | |
|[jstor](problems.md#jstor) |0.3.7 |__+1__ | | |
|[metacoder](problems.md#metacoder) |0.3.3 |__+1__ | |1 |
|[micropan](problems.md#micropan) |2.0 |__+1__ | | |
|[modeltests](problems.md#modeltests) |0.1.0 |__+1__ | | |
|[poio](problems.md#poio) |0.0-3 | |__+1__ |2 |
|[portalr](problems.md#portalr) |0.3.1 |__+1__ | | |
|[REDCapR](problems.md#redcapr) |0.10.2 |__+1__ | | |
|[rematch2](problems.md#rematch2) |2.1.1 |__+1__ | | |
|[RmarineHeatWaves](problems.md#rmarineheatwaves) |0.17.0 |__+1__ | | |
|[rsample](problems.md#rsample) |0.0.5 |__+1__ | | |
|[RSDA](problems.md#rsda) |3.0.1 |__+1__ | | |
|[rubias](problems.md#rubias) |0.3.0 |__+1__ | |2 |
|[SanzCircos](problems.md#sanzcircos) |0.1.0 |__+1__ | |1 |
|[simrel](problems.md#simrel) |2.0 |__+1__ | | |
|[tidytransit](problems.md#tidytransit) |0.7.0 |__+1__ | |2 |
|[tidytree](problems.md#tidytree) |0.3.2 | |__+1__ |1 |
|[viafr](problems.md#viafr) |0.1.0 |__+1__ | |1 |
|[vip](problems.md#vip) |0.2.1 |__+1__ | | |
## New problems (47)

|package |version |error |warning |note |
|:--------------------------------------------------|:-------|:------|:-------|:----|
|[AGread](problems.md#agread) |1.1.1 |__+1__ | |1 |
|[comparer](problems.md#comparer) |0.2.2 |__+1__ | |1 |
|[crosstable](problems.md#crosstable) |0.2.1 |__+1__ | | |
|[drake](problems.md#drake) |7.13.2 |__+1__ | | |
|[EFAtools](problems.md#efatools) |0.3.1 |__+1__ | |2 |
|[egor](problems.md#egor) |1.21.7 |__+2__ | | |
|[fgeo.tool](problems.md#fgeotool) |1.2.7 |__+1__ | | |
|[finetune](problems.md#finetune) |0.1.0 |__+1__ | |1 |
|[geonet](problems.md#geonet) |0.1.1 |__+1__ | | |
|[ggspatial](problems.md#ggspatial) |1.1.5 |__+1__ | | |
|[graphicalVAR](problems.md#graphicalvar) |0.2.4 |__+1__ | | |
|[grobblR](problems.md#grobblr) |0.2.0 |__+2__ | | |
|[heatwaveR](problems.md#heatwaver) |0.4.5 |__+1__ | | |
|[HEDA](problems.md#heda) |0.1.5 |__+1__ | | |
|[htmlTable](problems.md#htmltable) |2.2.1 |__+2__ | | |
|[hurricaneexposure](problems.md#hurricaneexposure) |0.1.1 |__+1__ | |1 |
|[impactr](problems.md#impactr) |0.1.0 |__+2__ | | |
|[isoreader](problems.md#isoreader) |1.3.0 |__+1__ | | |
|[ITNr](problems.md#itnr) |0.6.0 |__+1__ | | |
|[LexisNexisTools](problems.md#lexisnexistools) |0.3.4 |__+1__ | | |
|[lvmisc](problems.md#lvmisc) |0.1.1 |__+1__ | | |
|[mfGARCH](problems.md#mfgarch) |0.2.1 |__+1__ | | |
|[mortAAR](problems.md#mortaar) |1.1.1 |__+1__ | | |
|[msigdbr](problems.md#msigdbr) |7.4.1 |__+1__ | |1 |
|[OncoBayes2](problems.md#oncobayes2) |0.7-0 |__+1__ | |2 |
|[optimall](problems.md#optimall) |0.1.0 |__+2__ | | |
|[phenofit](problems.md#phenofit) |0.2.7 |__+2__ | |1 |
|[pitchRx](problems.md#pitchrx) |1.8.2 |__+1__ | |1 |
|[PKNCA](problems.md#pknca) |0.9.4 |__+1__ | | |
|[psychmeta](problems.md#psychmeta) |2.6.0 |__+2__ | |1 |
|[REddyProc](problems.md#reddyproc) |1.2.2 |__+1__ | | |
|[reproducer](problems.md#reproducer) |0.4.2 |__+1__ | | |
|[rubias](problems.md#rubias) |0.3.2 |__+1__ | |2 |
|[sapfluxnetr](problems.md#sapfluxnetr) |0.1.1 |__+2__ | |1 |
|[sim2Dpredictr](problems.md#sim2dpredictr) |0.1.0 |__+2__ | |1 |
|[SMMT](problems.md#smmt) |1.0.7 |__+1__ | | |
|[stacks](problems.md#stacks) |0.2.1 |__+1__ | |2 |
|[stevemisc](problems.md#stevemisc) |1.2.0 |__+1__ | |1 |
|[tablet](problems.md#tablet) |0.3.2 |__+1__ | | |
|[textrecipes](problems.md#textrecipes) |0.4.1 |__+1__ | | |
|[tidypredict](problems.md#tidypredict) |0.4.8 |__+1__ | | |
|[tune](problems.md#tune) |0.1.6 |__+1__ | | |
|[twoxtwo](problems.md#twoxtwo) |0.1.0 |__+1__ | | |
|[workflowsets](problems.md#workflowsets) |0.1.0 |__+1__ | | |
|[xpose4](problems.md#xpose4) |4.7.1 |__+2__ | | |
|[xrf](problems.md#xrf) |0.2.0 |__+1__ | | |
|[ypr](problems.md#ypr) |0.5.2 |__+1__ | | |

Loading