Skip to content

Commit

Permalink
Merge tag 'v3.0.2' into f-invariants
Browse files Browse the repository at this point in the history
tibble 3.0.2

- `[[` works with classed indexes again, e.g. created with `glue::glue()` (#778).
- `add_column()` works without warning for 0-column data frames (#786).
- `tribble()` now better handles named inputs (#775) and objects of non-vtrs classes like `lubridate::Period` (#784) and `formattable::formattable` (#785).

- Subsetting and subassignment are faster (#780, #790, #794).
- `is.null()` is preferred over `is_null()` for speed.
- Implement continuous benchmarking (#793).

- `is_vector_s3()` is no longer reexported from pillar (#789).
  • Loading branch information
krlmlr committed Feb 25, 2021
2 parents a7ccce4 + db9190e commit 7fff63b
Show file tree
Hide file tree
Showing 64 changed files with 731 additions and 346 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
^revdep$
^README-.*\.png$
^appveyor\.yml$
^bench$
^\.github$
^\.deploy_key\.pub$
^\.deploy_key\.enc$
^API$
Expand All @@ -29,3 +31,4 @@
^\.github/workflows/pr-commands\.yaml$
^tests/testthat/helper-rstudio\.R$
^vignettes/invariants\.md$
^bench$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/NAMESPACE merge=union
/.Rbuildignore merge=union
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you’ve found a bug, please file an issue that illustrates the bug with a mi
* New code should follow the tidyverse [style guide](https://style.tidyverse.org).
You can use the [styler](https://CRAN.R-project.org/package=styler) package to apply these styles, but please don't restyle code that has nothing to do with your PR.

* We use [roxygen2](https://cran.r-project.org/package=roxygen2), with [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/markdown.html), for documentation.
* We use [roxygen2](https://cran.r-project.org/package=roxygen2), with [Markdown syntax](https://roxygen2.r-lib.org/articles/rd-formatting.html), for documentation.

* We use [testthat](https://cran.r-project.org/package=testthat) for unit tests.
Contributions with test cases included are easier to accept.
Expand Down
45 changes: 31 additions & 14 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ jobs:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: '3.6'}
- {os: macOS-latest, r: '3.6'}
- {os: macOS-latest, r: 'devel'}
- {os: ubuntu-16.04, r: '3.3', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.4', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.5', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.6', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- {os: macOS-latest, r: 'devel'}
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: '4.0'}
- {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
CRAN: ${{ matrix.config.cran }}
RSPM: ${{ matrix.config.rspm }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
with:
Expand All @@ -40,8 +41,10 @@ jobs:
- uses: r-lib/actions/setup-pandoc@master

- name: Query dependencies
run:
Rscript -e "install.packages('remotes')" -e "saveRDS(remotes::dev_package_deps(dependencies = TRUE), 'depends.Rds', version = 2)"
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
Expand All @@ -62,11 +65,25 @@ jobs:
- name: Install dependencies
run:
Rscript -e "library(remotes)" -e "deps <- readRDS('depends.Rds')" -e "deps[['installed']] <- vapply(deps[['package']], remotes:::local_sha, character(1))" -e "update(deps)" -e "remotes::install_cran('rcmdcheck')"
Rscript -e "library(remotes)" -e "deps <- readRDS('.github/depends.Rds')" -e "deps[['installed']] <- vapply(deps[['package']], remotes:::local_sha, character(1))" -e "update(deps)" -e "remotes::install_cran('rcmdcheck')"

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
run:
Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'warning', check_dir = 'check')"
env:
_R_CHECK_CRAN_INCOMING_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "note", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/continuous-benchmarks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on: push

name: Continuous Benchmarks

jobs:
build:
runs-on: macOS-latest
steps:
- name: Checkout repo
uses: actions/checkout@master

- name: Setup R
uses: r-lib/actions/setup-r@master

- name: Install dependencies
run: |
install.packages("remotes")
remotes::install_deps(dependencies = TRUE)
remotes::install_github("r-lib/bench")
install.packages("here")
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Fetch existing benchmarks
run: Rscript -e 'bench::cb_fetch()' || true

- name: Run benchmarks
run: Rscript -e 'bench::cb_run()'

- name: Show benchmarks
run: git notes --ref benchmarks show

- name: Push benchmarks
run: Rscript -e "bench::cb_push()"
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tibble
Title: Simple Data Frames
Version: 3.0.1
Version: 3.0.2
Authors@R:
c(person(given = "Kirill",
family = "M\u00fcller",
Expand Down Expand Up @@ -49,10 +49,12 @@ Suggests:
covr,
dplyr,
evaluate,
formattable,
hms,
htmltools,
import,
knitr,
lubridate,
mockr,
nycflights13,
purrr,
Expand All @@ -62,9 +64,7 @@ Suggests:
withr
VignetteBuilder:
knitr
RdMacros:
lifecycle
Encoding: UTF-8
LazyData: yes
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1.9000
3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export(has_name)
export(has_rownames)
export(is.tibble)
export(is_tibble)
export(is_vector_s3)
export(knit_print.trunc_mat)
export(lst)
export(lst_)
Expand All @@ -77,7 +76,6 @@ import(lifecycle)
import(rlang)
importFrom(magrittr,"%>%")
importFrom(methods,setOldClass)
importFrom(pillar,is_vector_s3)
importFrom(pillar,new_pillar_title)
importFrom(pillar,new_pillar_type)
importFrom(pillar,obj_sum)
Expand All @@ -93,6 +91,7 @@ importFrom(vctrs,vec_as_location)
importFrom(vctrs,vec_as_location2)
importFrom(vctrs,vec_as_names)
importFrom(vctrs,vec_as_names_legacy)
importFrom(vctrs,vec_as_subscript2)
importFrom(vctrs,vec_c)
importFrom(vctrs,vec_is)
importFrom(vctrs,vec_rbind)
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# tibble 3.0.2

## Bug fixes

- `[[` works with classed indexes again, e.g. created with `glue::glue()` (#778).
- `add_column()` works without warning for 0-column data frames (#786).
- `tribble()` now better handles named inputs (#775) and objects of non-vtrs classes like `lubridate::Period` (#784) and `formattable::formattable` (#785).

## Performance

- Subsetting and subassignment are faster (#780, #790, #794).
- `is.null()` is preferred over `is_null()` for speed.
- Implement continuous benchmarking (#793).

## Compatibility

- `is_vector_s3()` is no longer reexported from pillar (#789).


# tibble 3.0.1

## Compatibility fixes
Expand Down
8 changes: 4 additions & 4 deletions R/add.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ add_column <- function(.data, ..., .before = NULL, .after = NULL,
deprecate_warn("2.1.1", "add_column(.data = 'must be a data frame')")
}

if ((!is_named(.data) || anyDuplicated(names2(.data))) && missing(.name_repair)) {
if (has_length(.data) && (!is_named(.data) || anyDuplicated(names2(.data))) && missing(.name_repair)) {
deprecate_warn("3.0.0", "add_column(.data = 'must have unique names')",
details = 'Use `.name_repair = "minimal"`.')
.name_repair <- "minimal"
Expand Down Expand Up @@ -176,14 +176,14 @@ pos_from_before_after_names <- function(before, after, names) {
}

pos_from_before_after <- function(before, after, len) {
if (is_null(before)) {
if (is_null(after)) {
if (is.null(before)) {
if (is.null(after)) {
len
} else {
limit_pos_range(after, len)
}
} else {
if (is_null(after)) {
if (is.null(after)) {
limit_pos_range(before - 1L, len)
} else {
cnd_signal(error_both_before_after())
Expand Down
11 changes: 7 additions & 4 deletions R/as_tibble.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Coerce lists, matrices, and more to data frames
#'
#' @description
#' \lifecycle{maturing}
#' `r lifecycle::badge("maturing")`
#'
#' `as_tibble()` turns an existing object, such as a data frame or
#' matrix, into a so-called tibble, a data frame with class [`tbl_df`]. This is
Expand Down Expand Up @@ -47,7 +47,7 @@
#' Read more in [rownames].

#' @param _n,validate
#' \lifecycle{soft-deprecated}
#' `r lifecycle::badge("soft-deprecated")`
#'
#' For compatibility only, do not use for new code.
#' @export
Expand Down Expand Up @@ -197,7 +197,7 @@ as_tibble.matrix <- function(x, ..., validate = NULL, .name_repair = NULL) {
names <- colnames(x)
if (is.null(.name_repair)) {
if ((is.null(names) || any(bad_names <- duplicated(names) | names == "")) && has_length(x)) {
deprecate_warn("2.0.0", "as_tibble.matrix(x = 'must have column names if `.name_repair` is omitted')",
deprecate_warn("2.0.0", "as_tibble.matrix(x = 'must have unique column names if `.name_repair` is omitted')",
details = "Using compatibility `.name_repair`.")
compat_names <- paste0("V", seq_along(m))
if (is.null(names)) {
Expand Down Expand Up @@ -273,6 +273,8 @@ as_tibble.default <- function(x, ...) {

#' @description
#' `as_tibble_row()` converts a vector to a tibble with one row.
#' The input must be a bare vector, e.g. vectors of dates are not
#' supported yet.
#' If the input is a list, all elements must have length one.
#'
#' @rdname as_tibble
Expand All @@ -286,6 +288,7 @@ as_tibble_row <- function(x,
.name_repair = c("check_unique", "unique", "universal", "minimal")) {

if (!is_bare_vector(x)) {
# FIXME: Remove entry from help once fixed (#797)
cnd_signal(error_as_tibble_row_bare(x))
}

Expand All @@ -310,7 +313,7 @@ check_all_lengths_one <- function(x) {


#' @description
#' `as_tibble_column()` converts a vector to a tibble with one column.
#' `as_tibble_col()` converts a vector to a tibble with one column.
#'
#' @param column_name Name of the column.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/compat-lazyeval.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ compat_lazy <- function(lazy, env = caller_env(), warn = TRUE) {
}
)

if (is_null(out)) {
if (is.null(out)) {
cnd_signal(sprintf("Can't convert a %s to a quosure", typeof(lazy)))
} else {
out
Expand Down
2 changes: 1 addition & 1 deletion R/deprecated.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Deprecated functions
#'
#' @description
#' \lifecycle{deprecated}
#' `r lifecycle::badge("deprecated")`
#'
#' Use [tibble()] instead of `data_frame()`.
#'
Expand Down
10 changes: 5 additions & 5 deletions R/enframe.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Converting vectors to data frames, and vice versa
#'
#' @description
#' \lifecycle{maturing}
#' `r lifecycle::badge("maturing")`
#'
#' `enframe()` converts named atomic vectors or lists to one- or two-column
#' data frames.
Expand All @@ -22,19 +22,19 @@
#' enframe(c(a = 5, b = 7))
#' enframe(list(one = 1, two = 2:3, three = 4:6))
enframe <- function(x, name = "name", value = "value") {
if (is_null(value)) {
if (is.null(value)) {
cnd_signal(error_enframe_value_null())
}

if (length(dim(x)) > 1) {
cnd_signal(error_enframe_has_dim(x))
}

if (is_null(x)) x <- logical()
if (is.null(x)) x <- logical()

if (is_null(name)) {
if (is.null(name)) {
df <- list(unname(x))
} else if (is_null(names(x))) {
} else if (is.null(names(x))) {
df <- list(seq_along(x), x)
} else {
df <- list(names(x), unname(x))
Expand Down
8 changes: 4 additions & 4 deletions R/glimpse.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Get a glimpse of your data
#'
#' @description
#' \lifecycle{maturing}
#' `r lifecycle::badge("maturing")`
#'
#' `glimpse()` is like a transposed version of `print()`:
#' columns run down the page, and data runs across.
Expand All @@ -28,9 +28,9 @@
#' @examples
#' glimpse(mtcars)
#'
#' if (requireNamespace("nycflights13", quietly = TRUE)) {
#' glimpse(nycflights13::flights)
#' }
#' @examplesIf requireNamespace("nycflights13", quietly = TRUE)
#' glimpse(nycflights13::flights)
#'
# Can be overridden in .onLoad()
glimpse <- function(x, width = NULL, ...) {
UseMethod("glimpse")
Expand Down
16 changes: 16 additions & 0 deletions R/legacy-compat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# For RSDA package
tbl_subset_col <- function(x, j, j_arg) {
if (is.null(j)) return(x)

j <- vectbl_as_col_location(j, length(x), names(x), j_arg = j_arg, assign = FALSE)

if (anyNA(j)) {
cnd_signal(error_na_column_index(which(is.na(j))))
}

xo <- .subset(x, j)
if (anyDuplicated(j)) {
xo <- set_repaired_names(xo, .name_repair = "minimal")
}
set_tibble_class(xo, nrow = fast_nrow(x))
}
Loading

0 comments on commit 7fff63b

Please sign in to comment.