Skip to content

Releases: r-lib/vctrs

vctrs 0.7.1

27 Jan 14:09
eea0f70

Choose a tag to compare

  • Fixed some protection issues discovered by rchk.

vctrs 0.7.0

16 Jan 14:30
a0ccfff

Choose a tag to compare

Features

  • New vec_if_else() for performing a vectorized if-else. It is exactly the same as dplyr::if_else(), but much faster and more memory efficient (#2030).

  • New vec_case_when() and vec_replace_when() for recoding and replacing using logical conditions (#2024).

  • New vec_recode_values() and vec_replace_values() for recoding and replacing values. In particular, this makes it easy to recode a vector using a lookup table (#2027).

  • New list_combine() for combining a list of vectors together according to a set of indices. We now recommend using:

    • list_combine(x, indices = indices, size = size) over list_unchop(x, indices = indices)
    • vec_c(!!!x) over list_unchop(x)

    list_unchop() is not being deprecated, we just no longer feel like it has the best name or the most correct API, and all future work will be put into improving list_combine(). list_combine() is already much more powerful than list_unchop(), with new unmatched, multiple, and slice_x (like slice_value of vec_assign()) arguments and the ability to provide logical indices.

    list_combine() is the engine that powers vec_case_when(), vec_replace_when(), vec_recode_values(), vec_replace_values(), and parts of vec_if_else().

  • New vec_pany() and vec_pall(), parallel variants of any() and all() (in the same way that pmin() and pmax() are parallel variants of min() and max()).

  • New list_of_transpose() for transposing a <list_of> (#2059).

  • New list_of_ptype() and list_of_size() accessors.

  • New vec_check_recyclable(), list_all_recyclable(), and list_check_all_recyclable().

  • New slice_value argument for vec_assign() to optionally slice value by i before performing the assignment. It is an optimized form of vec_slice(x, i) <- vec_slice(value, i) that avoids materializing vec_slice(value, i) (#2009).

  • New .size argument for list_of() that can restrict the element size in addition to the element type. For example:

    # Restricts the element type, but not the size (default behavior)
    list_of(1:2, 3:4, .ptype = integer(), .size = zap())
    
    # Restricts the element size, but not the type
    list_of(1:2, 3:4, .ptype = zap(), .size = 2)
    
    # Restricts the element type and size
    list_of(1:2, 3:4, .ptype = integer(), .size = 2)
  • New .name_spec = "inner" option for vec_c(), list_unchop(), and vec_rbind(). This efficiently ignores all outer names, while retaining any inner names (#1988).

  • New allow_null argument for list_all_vectors(), list_all_size(), list_check_all_vectors(), and list_check_all_size(), which skips over NULL when performing their respective check (#1762).

  • New .size and .error_call arguments for vec_interleave().

  • New .finalise argument for vec_ptype_common() that defaults to TRUE. Setting this to FALSE lets you opt out of prototype finalisation, which allows vec_ptype_common() to act like vec_ptype() and vec_ptype2(), which don't finalise. This can be useful in some advanced common type determination cases (#2100).

  • The following functions are no longer experimental:

    • vec_fill_missing()
    • vec_group_id()
    • vec_group_loc()
    • vec_group_rle()
    • vec_locate_matches()

Bug fixes

  • data.table's IDate class now has vec_proxy() and vec_restore() methods, fixing a number of issues with that class (#1549, #1961, #1972, #1781).

  • vec_detect_complete(NULL) now returns logical(), consistent with vec_detect_missing(NULL) (#1916).

  • vec_assign() no longer modifies POSIXlt and vctrs_rcrd types in place (#1951).

  • vec_interleave() now reports the correct index in errors when NULLs are present.

  • list_unchop() now assigns names correctly when overlapping indices are involved (#2019).

  • list_unchop() now works in an edge case with a single NA recycled to size 0 (#1989).

  • list_unchop() now correctly respects indices when combining fallback data frame columns (#1975).

  • vec_locate_sorted_groups() and vec_order_radix() no longer crash on columns of type complex (tidyverse/dplyr#7708).

  • Hashing is now supported for lists containing complex or raw vectors, enabling functions like vec_unique_loc() to work on these objects (#1992, #2046).

  • obj_check_vector() now throws a clearer error message. In particular, special info bullets have been added that link out to FAQ pages and explain common issues around incompatible S3 lists and data frames (#2061).

  • vec_rank() now throws an improved error on non-vector types, like NULL (#1967).

  • vec_ptype_common() now reports more accurate error argument names (#2048).

  • Fixed the C level signature for the exp_short_init_compact_seq() callable.

  • Methods for the deprecated testthat function is_informative_error() have been removed (#2089).

Performance

  • vec_c(), list_unchop(), vec_size_common(), vec_recycle_common(), vec_ptype_common(), list_sizes(), list_check_all_vectors(), and other vctrs functions that take a list of objects are now more performant, particularly when many small objects are provided (#2034, #2035, #2041, #2042, #2043, #2044, #2070).

  • vec_match(), vec_in(), vec_group_loc(), vec_count(), vec_unique() and other functions backed by a dictionary based implementation are often significantly faster, depending on the exact inputs used (#1976).

  • vec_equal() now efficiently internally recycles x and y elements of size 1 (#2028).

  • list_unchop() now efficiently internally recycles x elements of size 1 (#2013).

  • vec_assign() and vec_slice<-() now efficiently internally recycle value of size 1.

  • vec_assign() and vec_slice<-() are now more efficient with logical i (#2009).

  • vec_cast() with arrays no longer clones when no casting is required (#2006).

Breaking changes

  • R >=4.0.0 is now required. This is still more permissive than the general tidyverse policy of supporting the 5 most recent versions of R.

  • obj_is_list() now returns FALSE for list arrays. Functions such as list_drop_empty() and list_combine() validate their input using obj_is_list(), but aren't well defined on list arrays.

  • Assigning NULL into a <list_of> via x[[i]] <- NULL now shortens the list to better align with base R and the existing $<- and [<- methods (#2112).

  • as_list_of() on an existing <list_of> no longer has a .ptype argument for changing the type on the fly, as this feels incompatible with the new system that allows restricting both the type and size. If you really need this, coerce to a bare list with as.list() first, then coerce back to a <list_of> using the <list> method of as_list_of().

  • Experimental "partial" type support has been removed. This idea never panned out and was not widely used. The following functions have been removed (#2101):

    • is_partial()
    • new_partial()
    • partial_factor()
    • partial_frame()
  • The deprecated C callable for vec_is_vector() has been removed.

vctrs 0.6.5

04 Dec 13:44

Choose a tag to compare

  • Internal changes requested by CRAN around C level format strings (#1896).

  • Fixed tests related to changes to dim<-() in R-devel (#1889).

vctrs 0.6.4

13 Oct 13:09
47a1a7f

Choose a tag to compare

  • Fixed a performance issue with vec_c() and ALTREP vectors (in particular,
    the new ALTREP list vectors in R-devel) (#1884).

  • Fixed an issue with complex vector tests related to changes in R-devel
    (#1883).

  • Added a class to the vec_locate_matches() error that is thrown when an
    overflow would otherwise occur (#1845).

  • Fixed an issue with vec_rank() and 0-column data frames (#1863).

vctrs 0.6.3

15 Jun 14:28
acafad5

Choose a tag to compare

  • Fixed an issue where certain ALTREP row names were being materialized when
    passed to new_data_frame(). We've fixed this by removing a safeguard in
    new_data_frame() that performed a compatibility check when both n and
    row.names were provided. Because this is a low level function designed for
    performance, it is up to the caller to ensure these inputs are compatible
    (tidyverse/dplyr#6596).

  • Fixed an issue where vec_set_*() used with data frames could accidentally
    return an object with the type of the proxy rather than the type of the
    original inputs (#1837).

  • Fixed a rare vec_locate_matches() bug that could occur when using a max/min
    filter (tidyverse/dplyr#6835).

vctrs 0.6.2

19 Apr 20:01
9455e2e

Choose a tag to compare

  • Fixed conditional S3 registration to avoid a CRAN check NOTE that appears in
    R >=4.3.0 (#1832).

  • Fixed tests to maintain compatibility with the next version of waldo (#1829).

vctrs 0.6.1

22 Mar 15:01
f810b9e

Choose a tag to compare

  • Fixed a test related to c.sfc() changes in sf 1.0-10 (#1817).

vctrs 0.6.0

16 Mar 13:03
dcf57e9

Choose a tag to compare

  • New vec_run_sizes() for computing the size of each run within a vector. It
    is identical to the times column from vec_unrep(), but is faster if you
    don't need the run key (#1210).

  • New sizes argument to vec_chop() which allows you to partition a vector
    using an integer vector describing the size of each expected slice. It is
    particularly useful in combination with vec_run_sizes() and list_sizes()
    (#1210, #1598).

  • New obj_is_vector(), obj_check_vector(), and vec_check_size() validation
    helpers. We believe these are a better approach to vector validation than
    vec_assert() and vec_is(), which have been marked as questioning because
    the semantics of their ptype arguments are hard to define and can often be
    replaced by vec_cast() or a type predicate function like
    rlang::is_logical() (#1784).

  • vec_is_list() and vec_check_list() have been renamed to obj_is_list()
    and obj_check_list(), in line with the new obj_is_vector() helper. The
    old functions have been silently deprecated, but an official deprecation
    process will start in the next vctrs release (#1803).

  • vec_locate_matches() gains a new relationship argument that holistically
    handles multiple matches between needles and haystack. In particular,
    relationship = "many-to-one" replaces multiple = "error" and
    multiple = "warning", which have been removed from the documentation and
    silently soft-deprecated. Official deprecation for those options will start in
    a future release (#1791).

  • vec_locate_matches() has changed its default needles_arg and
    haystack_arg values from "" to "needles" and "haystack", respectively.
    This generally generates more informative error messages (#1792).

  • vec_chop() has gained empty ... between x and the optional indices
    argument. For backwards compatibility, supplying vec_chop(x, indices)
    without naming indices still silently works, but will be deprecated in a
    future release (#1813).

  • vec_slice() has gained an error_call argument (#1785).

  • The numeric_version type from base R is now better supported in equality,
    comparison, and order based operations (tidyverse/dplyr#6680).

  • R >=3.5.0 is now explicitly required. This is in line with the tidyverse
    policy of supporting the 5 most recent versions of
    R
    .

vctrs 0.5.2

23 Jan 13:50
8632e52

Choose a tag to compare

  • New vec_expand_grid(), which is a lower level helper that is similar to
    tidyr::expand_grid() (#1325).

  • New vec_set_intersect(), vec_set_difference(), vec_set_union(), and
    vec_set_symmetric_difference() which compute set operations like
    intersect(), setdiff(), and union(), but the vctrs variants don't strip
    attributes and work with data frames (#1755, #1765).

  • vec_identify_runs() is now faster when used with data frames (#1684).

  • The maximum load factor of the internal dictionary was reduced from 77% to
    50%, which improves performance of functions like vec_match(),
    vec_set_intersect(), and vec_unique() in some cases (#1760).

  • Fixed a bug with the internal vec_order_radix() function related to matrix
    columns (#1753).

vctrs 0.5.1

16 Nov 15:44

Choose a tag to compare

  • Fix for CRAN checks.