vctrs 0.4.0
-
New experimental
vec_locate_sorted_groups()
for returning the locations of
groups in sorted order. This is equivalent to, but faster than, calling
vec_group_loc()
and then sorting by thekey
column of the result. -
New experimental
vec_locate_matches()
for locating where each observation
in one vector matches one or more observations in another vector. It is
similar tovec_match()
, but returns all matches by default (rather than just
the first), and can match on binary conditions other than equality. The
algorithm is inspired by data.table's very fast binary merge procedure. -
The
vec_proxy_equal()
,vec_proxy_compare()
, andvec_proxy_order()
methods forvctrs_rcrd
are now applied recursively over the fields (#1503). -
Lossy cast errors now inherit from incompatible type errors.
-
vec_is_list()
now returnsTRUE
forAsIs
lists (#1463). -
vec_assert()
,vec_ptype2()
,vec_cast()
, andvec_as_location()
now usecaller_arg()
to infer a defaultarg
value from the
caller.This may result in unhelpful arguments being mentioned in error
messages. In general, you should consider snapshotting vctrs error
messages thrown in your package and supplyarg
andcall
arguments if the error context is not adequately reported to your
users. -
vec_ptype_common()
,vec_cast_common()
,vec_size_common()
, and
vec_recycle_common()
gaincall
andarg
arguments for
specifying an error context. -
vec_compare()
can now compare zero column data frames (#1500). -
new_data_frame()
now errors on negative and missingn
values (#1477). -
vec_order()
now correctly orders zero column data frames (#1499). -
vctrs now depends on cli to help with error message generation.
-
New
vec_check_list()
andlist_check_all_vectors()
input
checkers, and an accompanyinglist_all_vectors()
predicate. -
New
vec_interleave()
for combining multiple vectors together, interleaving
their elements in the process (#1396). -
vec_equal_na(NULL)
now returnslogical(0)
rather than erroring (#1494). -
vec_as_location(missing = "error")
now fails withNA
andNA_character_
in addition toNA_integer_
(#1420, @krlmlr). -
Starting with rlang 1.0.0, errors are displayed with the contextual
function call. Several vctrs operations gain acall
argument that
makes it possible to report the correct context in error messages.
This concerns:vec_cast()
andvec_ptype2()
vec_default_cast()
andvec_default_ptype2()
vec_assert()
vec_as_names()
stop_
constructors likestop_incompatible_type()
Note that default
vec_cast()
andvec_ptype2()
methods
automatically support this if they pass...
to the corresponding
vec_default_
functions. If you throw a non-internal error from a
non-default method, add acall = caller_env()
argument in the
method and pass it torlang::abort()
. -
If
NA_character_
is specified as a name forvctrs_vctr
objects, it is
now automatically repaired to""
(#780). -
""
is now an allowed name forvctrs_vctr
objects and all its
subclasses (vctrs_list_of
in particular) (#780). -
list_of()
is now much faster when many values are provided. -
vec_as_location()
evaluatesarg
only in case of error, for performance
(#1150, @krlmlr). -
levels.vctrs_vctr()
now returnsNULL
instead of failing (#1186, @krlmlr). -
vec_assert()
produces a more informative error whensize
is invalid
(#1470). -
vec_duplicate_detect()
is a bit faster when there are many unique values. -
vec_proxy_order()
is described invignette("s3-vectors")
(#1373, @krlmlr). -
vec_chop()
now materializes ALTREP vectors before chopping, which is more
efficient than creating many small ALTREP pieces (#1450). -
New
list_drop_empty()
for removing empty elements from a list (#1395). -
list_sizes()
now propagates the names of the list onto the result. -
Name repair messages are now signaled by
rlang::names_inform_repair()
. This
means that the messages are now sent to stdout by default rather than to
stderr, resulting in prettier messages. Additionally, name repair messages can
now be silenced through the global optionrlib_name_repair_verbosity
, which
is useful for testing purposes. See?names_inform_repair
for more
information (#1429). -
vctrs_vctr
methods forna.omit()
,na.exclude()
, andna.fail()
have
been added (#1413). -
vec_init()
is now slightly faster (#1423). -
vec_set_names()
no longer corruptsvctrs_rcrd
types (#1419). -
vec_detect_complete()
now computes completeness forvctrs_rcrd
types in
the same way as data frames, which means that if any field is missing, the
entire record is considered incomplete (#1386). -
The
na_value
argument ofvec_order()
andvec_sort()
now correctly
respect missing values in lists (#1401). -
vec_rep()
andvec_rep_each()
are much faster fortimes = 0
and
times = 1
(@mgirlich, #1392). -
vec_equal_na()
andvec_fill_missing()
now work with integer64 vectors
(#1304). -
The
xtfrm()
method for vctrs_vctr objects no longer accidentally breaks
ties (#1354). -
min()
,max()
andrange()
no longer throw an error ifna.rm = TRUE
is
set and all values areNA
(@gorcha, #1357). In this case, and where an empty
input is given, it will returnInf
/-Inf
, orNA
ifInf
can't be cast
to the input type. -
vec_group_loc()
, used for grouping in dplyr, now correctly handles
vectors with billions of elements (up to.Machine$integer.max
) (#1133).