Releases: r-lib/vctrs
vctrs 0.7.1
- Fixed some protection issues discovered by rchk.
vctrs 0.7.0
Features
-
New
vec_if_else()for performing a vectorized if-else. It is exactly the same asdplyr::if_else(), but much faster and more memory efficient (#2030). -
New
vec_case_when()andvec_replace_when()for recoding and replacing using logical conditions (#2024). -
New
vec_recode_values()andvec_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 ofindices. We now recommend using:list_combine(x, indices = indices, size = size)overlist_unchop(x, indices = indices)vec_c(!!!x)overlist_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 improvinglist_combine().list_combine()is already much more powerful thanlist_unchop(), with newunmatched,multiple, andslice_x(likeslice_valueofvec_assign()) arguments and the ability to provide logicalindices.list_combine()is the engine that powersvec_case_when(),vec_replace_when(),vec_recode_values(),vec_replace_values(), and parts ofvec_if_else(). -
New
vec_pany()andvec_pall(), parallel variants ofany()andall()(in the same way thatpmin()andpmax()are parallel variants ofmin()andmax()). -
New
list_of_transpose()for transposing a<list_of>(#2059). -
New
list_of_ptype()andlist_of_size()accessors. -
New
vec_check_recyclable(),list_all_recyclable(), andlist_check_all_recyclable(). -
New
slice_valueargument forvec_assign()to optionally slicevaluebyibefore performing the assignment. It is an optimized form ofvec_slice(x, i) <- vec_slice(value, i)that avoids materializingvec_slice(value, i)(#2009). -
New
.sizeargument forlist_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 forvec_c(),list_unchop(), andvec_rbind(). This efficiently ignores all outer names, while retaining any inner names (#1988). -
New
allow_nullargument forlist_all_vectors(),list_all_size(),list_check_all_vectors(), andlist_check_all_size(), which skips overNULLwhen performing their respective check (#1762). -
New
.sizeand.error_callarguments forvec_interleave(). -
New
.finaliseargument forvec_ptype_common()that defaults toTRUE. Setting this toFALSElets you opt out of prototype finalisation, which allowsvec_ptype_common()to act likevec_ptype()andvec_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
IDateclass now hasvec_proxy()andvec_restore()methods, fixing a number of issues with that class (#1549, #1961, #1972, #1781). -
vec_detect_complete(NULL)now returnslogical(), consistent withvec_detect_missing(NULL)(#1916). -
vec_assign()no longer modifiesPOSIXltandvctrs_rcrdtypes in place (#1951). -
vec_interleave()now reports the correct index in errors whenNULLs are present. -
list_unchop()now assigns names correctly when overlappingindicesare involved (#2019). -
list_unchop()now works in an edge case with a singleNArecycled to size 0 (#1989). -
list_unchop()now correctly respectsindiceswhen combining fallback data frame columns (#1975). -
vec_locate_sorted_groups()andvec_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, likeNULL(#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 recyclesxandyelements of size 1 (#2028). -
list_unchop()now efficiently internally recyclesxelements of size 1 (#2013). -
vec_assign()andvec_slice<-()now efficiently internally recyclevalueof size 1. -
vec_assign()andvec_slice<-()are now more efficient with logicali(#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 returnsFALSEfor list arrays. Functions such aslist_drop_empty()andlist_combine()validate their input usingobj_is_list(), but aren't well defined on list arrays. -
Assigning
NULLinto a<list_of>viax[[i]] <- NULLnow 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.ptypeargument 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 withas.list()first, then coerce back to a<list_of>using the<list>method ofas_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
vctrs 0.6.4
-
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
-
Fixed an issue where certain ALTREP row names were being materialized when
passed tonew_data_frame(). We've fixed this by removing a safeguard in
new_data_frame()that performed a compatibility check when bothnand
row.nameswere 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
vctrs 0.6.1
- Fixed a test related to
c.sfc()changes in sf 1.0-10 (#1817).
vctrs 0.6.0
-
New
vec_run_sizes()for computing the size of each run within a vector. It
is identical to thetimescolumn fromvec_unrep(), but is faster if you
don't need the run key (#1210). -
New
sizesargument tovec_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 withvec_run_sizes()andlist_sizes()
(#1210, #1598). -
New
obj_is_vector(),obj_check_vector(), andvec_check_size()validation
helpers. We believe these are a better approach to vector validation than
vec_assert()andvec_is(), which have been marked as questioning because
the semantics of theirptypearguments are hard to define and can often be
replaced byvec_cast()or a type predicate function like
rlang::is_logical()(#1784). -
vec_is_list()andvec_check_list()have been renamed toobj_is_list()
andobj_check_list(), in line with the newobj_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 newrelationshipargument that holistically
handles multiple matches betweenneedlesandhaystack. In particular,
relationship = "many-to-one"replacesmultiple = "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 defaultneedles_argand
haystack_argvalues from""to"needles"and"haystack", respectively.
This generally generates more informative error messages (#1792). -
vec_chop()has gained empty...betweenxand the optionalindices
argument. For backwards compatibility, supplyingvec_chop(x, indices)
without namingindicesstill silently works, but will be deprecated in a
future release (#1813). -
vec_slice()has gained anerror_callargument (#1785). -
The
numeric_versiontype 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
-
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(), andunion(), 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 likevec_match(),
vec_set_intersect(), andvec_unique()in some cases (#1760). -
Fixed a bug with the internal
vec_order_radix()function related to matrix
columns (#1753).
vctrs 0.5.1
- Fix for CRAN checks.