1# vctrs 0.3.8
2
3* Compatibility with next version of rlang.
4
5
6# vctrs 0.3.7
7
8* `vec_ptype_abbr()` gains arguments to control whether to indicate
9  named vectors with a prefix (`prefix_named`) and indicate shaped
10  vectors with a suffix (`suffix_shape`) (#781, @krlmlr).
11
12* `vec_ptype()` is now an optional _performance_ generic. It is not necessary
13  to implement, but if your class has a static prototype, you might consider
14  implementing a custom `vec_ptype()` method that returns a constant to
15  improve performance in some cases (such as common type imputation).
16
17* New `vec_detect_complete()`, inspired by `stats::complete.cases()`. For most
18  vectors, this is identical to `!vec_equal_na()`. For data frames and
19  matrices, this detects rows that only contain non-missing values.
20
21* `vec_order()` can now order complex vectors (#1330).
22
23* Removed dependency on digest in favor of `rlang::hash()`.
24
25* Fixed an issue where `vctrs_rcrd` objects were not being proxied correctly
26  when used as a data frame column (#1318).
27
28* `register_s3()` is now licensed with the "unlicense" which makes it very
29  clear that it's fine to copy and paste into your own package
30  (@maxheld83, #1254).
31
32# vctrs 0.3.6
33
34* Fixed an issue with tibble 3.0.0 where removing column names with
35  `names(x) <- NULL` is now deprecated (#1298).
36
37* Fixed a GCC 11 issue revealed by CRAN checks.
38
39
40# vctrs 0.3.5
41
42* New experimental `vec_fill_missing()` for filling in missing values with
43  the previous or following value. It is similar to `tidyr::fill()`, but
44  also works with data frames and has an additional `max_fill` argument to
45  limit the number of sequential missing values to fill.
46
47* New `vec_unrep()` to compress a vector with repeated values. It is very
48  similar to run length encoding, and works nicely alongside `vec_rep_each()`
49  as a way to invert the compression.
50
51* `vec_cbind()` with only empty data frames now preserves the common size of
52  the inputs in the result (#1281).
53
54* `vec_c()` now correctly returns a named result with named empty inputs
55  (#1263).
56
57* vctrs has been relicensed as MIT (#1259).
58
59* Functions that make comparisons within a single vector, such as
60  `vec_unique()`, or between two vectors, such as `vec_match()`, now
61  convert all character input to UTF-8 before making comparisons (#1246).
62
63* New `vec_identify_runs()` which returns a vector of identifiers for the
64  elements of `x` that indicate which run of repeated values they fall in
65  (#1081).
66
67* Fixed an encoding translation bug with lists containing data frames which
68  have columns where `vec_size()` is different from the low level
69  `Rf_length()` (#1233).
70
71
72# vctrs 0.3.4
73
74* Fixed a GCC sanitiser error revealed by CRAN checks.
75
76
77# vctrs 0.3.3
78
79* The `table` class is now implemented as a wrapper type that
80  delegates its coercion methods. It used to be restricted to integer
81  tables (#1190).
82
83* Named one-dimensional arrays now behave consistently with simple
84  vectors in `vec_names()` and `vec_rbind()`.
85
86* `new_rcrd()` now uses `df_list()` to validate the fields. This makes
87  it more flexible as the fields can now be of any type supported by
88  vctrs, including data frames.
89
90* Thanks to the previous change the `[[` method of records now
91  preserves list fields (#1205).
92
93* `vec_data()` now preserves data frames. This is consistent with the
94  notion that data frames are a primitive vector type in vctrs. This
95  shouldn't affect code that uses `[[` and `length()` to manipulate
96  the data. On the other hand, the vctrs primitives like `vec_slice()`
97  will now operate rowwise when `vec_data()` returns a data frame.
98
99* `outer` is now passed unrecycled to name specifications. Instead,
100  the return value is recycled (#1099).
101
102* Name specifications can now return `NULL`. The names vector will
103  only be allocated if the spec function returns non-`NULL` during the
104  concatenation. This makes it possible to ignore outer names without
105  having to create an empty names vector when there are no inner
106  names:
107
108  ```
109  zap_outer_spec <- function(outer, inner) if (is_character(inner)) inner
110
111  # `NULL` names rather than a vector of ""
112  names(vec_c(a = 1:2, .name_spec = zap_outer_spec))
113  #> NULL
114
115  # Names are allocated when inner names exist
116  names(vec_c(a = 1:2, c(b = 3L), .name_spec = zap_outer_spec))
117  #> [1] ""  ""  "b"
118  ```
119
120* Fixed several performance issues in `vec_c()` and `vec_unchop()`
121  with named vectors.
122
123* The restriction that S3 lists must have a list-based proxy to be considered
124  lists by `vec_is_list()` has been removed (#1208).
125
126* New performant `data_frame()` constructor for creating data frames in a way
127  that follows tidyverse semantics. Among other things, inputs are recycled
128  using tidyverse recycling rules, strings are never converted to factors,
129  list-columns are easier to create, and unnamed data frame input is
130  automatically spliced.
131
132* New `df_list()` for safely and consistently constructing the data structure
133  underlying a data frame, a named list of equal-length vectors. It is useful
134  in combination with `new_data_frame()` for creating user-friendly
135  constructors for data frame subclasses that use the tidyverse rules for
136  recycling and determining types.
137
138* Fixed performance issue with `vec_order()` on classed vectors which
139  affected `dplyr::group_by()` (tidyverse/dplyr#5423).
140
141* `vec_set_names()` no longer alters the input in-place (#1194).
142
143* New `vec_proxy_order()` that provides an ordering proxy for use in
144  `vec_order()` and `vec_sort()`. The default method falls through to
145  `vec_proxy_compare()`. Lists are special cased, and return an integer
146  vector proxy that orders by first appearance.
147
148* List columns in data frames are no longer comparable through `vec_compare()`.
149
150* The experimental `relax` argument has been removed from
151  `vec_proxy_compare()`.
152
153
154# vctrs 0.3.2
155
156* Fixed a performance issue in `bind_rows()` with S3 columns (#1122,
157  #1124, #1151, tidyverse/dplyr#5327).
158
159* `vec_slice()` now checks sizes of data frame columns in case the
160  data structure is corrupt (#552).
161
162* The native routines in vctrs now dispatch and evaluate in the vctrs
163  namespace. This improves the continuity of evaluation in backtraces.
164
165* `new_data_frame()` is now twice as fast when `class` is supplied.
166
167* New `vec_names2()`, `vec_names()` and `vec_set_names()` (#1173).
168
169
170# vctrs 0.3.1
171
172* `vec_slice()` no longer restores attributes of foreign objects for
173  which a `[` method exist. This fixes an issue with `ts` objects
174  which were previously incorrectly restored.
175
176* The `as.list()` method for `vctrs_rcrd` objects has been removed in favor
177  of directly using the method for `vctrs_vctr`, which calls `vec_chop()`.
178
179* `vec_c()` and `vec_rbind()` now fall back to `base::c()` if the
180  inputs have a common class hierarchy for which a `c()` method is
181  implemented but no self-to-self `vec_ptype2()` method is
182  implemented.
183
184* `vec_rbind()` now internally calls `vec_proxy()` and `vec_restore()` on
185  the data frame common type that is used to create the output (#1109).
186
187* `vec_as_location2("0")` now works correctly (#1131).
188
189* `?reference-faq-compatibility` is a new reference guide on vctrs
190  primitives. It includes an overview of the fallbacks to base R
191  generics implemented in vctrs for compatibility with existing
192  classes.
193
194* The documentation of vctrs functions now includes a Dependencies
195  section to reference which other vctrs operations are called from
196  that function. By following the dependencies links recursively, you
197  will find the vctrs primitives on which an operation relies.
198
199
200## CRAN results
201
202* Fixed type declaration mismatches revealed by LTO build.
203* Fixed r-devel issue with new `c.factor()` method.
204
205
206# vctrs 0.3.0
207
208This version features an overhaul of the coercion system to make it
209more consistent and easier to implement. See the _Breaking changes_
210and _Type system_ sections for details.
211
212There are three new documentation topics if you'd like to learn how to
213implement coercion methods to make your class compatible with
214tidyverse packages like dplyr:
215
216* https://vctrs.r-lib.org/reference/theory-faq-coercion.html for an
217  overview of the coercion mechanism in vctrs.
218
219* https://vctrs.r-lib.org/reference/howto-faq-coercion.html for a
220  practical guide about implementing methods for vectors.
221
222* https://vctrs.r-lib.org/reference/howto-faq-coercion-data-frame.html
223  for a practical guide about implementing methods for data frames.
224
225
226## Reverse dependencies troubleshooting
227
228The following errors are caused by breaking changes.
229
230* `"Can't convert <character> to <list>."`
231
232  `vec_cast()` no longer converts to list. Use `vec_chop()` or
233  `as.list()` instead.
234
235* `"Can't convert <integer> to <character>."`
236
237  `vec_cast()` no longer converts to character. Use `as.character()`to
238  deparse objects.
239
240* `"names for target but not for current"`
241
242  Names of list-columns are now preserved by `vec_rbind()`. Adjust
243  tests accordingly.
244
245
246## Breaking changes
247
248* Double-dispatch methods for `vec_ptype2()` and `vec_cast()` are no
249  longer inherited (#710). Class implementers must implement one set
250  of methods for each compatible class.
251
252  For example, a tibble subclass no longer inherits from the
253  `vec_ptype2()` methods between `tbl_df` and `data.frame`. This means
254  that you explicitly need to implement `vec_ptype2()` methods with
255  `tbl_df` and `data.frame`.
256
257  This change requires a bit more work from class maintainers but is
258  safer because the coercion hierarchies are generally different from
259  class hierarchies. See the S3 dispatch section of `?vec_ptype2` for
260  more information.
261
262* `vec_cast()` is now restricted to the same conversions as
263  `vec_ptype2()` methods (#606, #741). This change is motivated by
264  safety and performance:
265
266  - It is generally sloppy to generically convert arbitrary inputs to
267    one type. Restricted coercions are more predictable and allow your
268    code to fail earlier when there is a type issue.
269
270  - When unrestricted conversions are useful, this is generally
271    towards a known type. For example, `glue::glue()` needs to convert
272    arbitrary inputs to the known character type. In this case, using
273    double dispatch instead of a single dispatch generic like
274   `as.character()` is wasteful.
275
276  - To implement the useful semantics of coercible casts (already used
277    in `vec_assign()`), two double dispatch were needed. Now it can be
278    done with one double dispatch by calling `vec_cast()` directly.
279
280* `stop_incompatible_cast()` now throws an error of class
281  `vctrs_error_incompatible_type` rather than `vctrs_error_incompatible_cast`.
282  This means that `vec_cast()` also throws errors of this class, which better
283  aligns it with `vec_ptype2()` now that they are restricted to the same
284  conversions.
285
286* The `y` argument of `stop_incompatible_cast()` has been renamed to `to` to
287  better match `to_arg`.
288
289
290## Type system
291
292* Double-dispatch methods for `vec_ptype2()` and `vec_cast()` are now
293  easier to implement. They no longer need any the boiler plate.
294  Implementing a method for classes `foo` and `bar` is now as simple as:
295
296  ```
297  #' @export
298  vec_ptype2.foo.bar <- function(x, y, ...) new_foo()
299  ```
300
301  vctrs also takes care of implementing the default and unspecified
302  methods. If you have implemented these methods, they are no longer
303  called and can now be removed.
304
305  One consequence of the new dispatch mechanism is that `NextMethod()`
306  is now completely unsupported. This is for the best as it never
307  worked correctly in a double-dispatch setting. Parent methods must
308  now be called manually.
309
310* `vec_ptype2()` methods now get zero-size prototypes as inputs. This
311  guarantees that methods do not peek at the data to determine the
312  richer type.
313
314* `vec_is_list()` no longer allows S3 lists that implement a `vec_proxy()`
315  method to automatically be considered lists. A S3 list must explicitly
316  inherit from `"list"` in the base class to be considered a list.
317
318* `vec_restore()` no longer restores row names if the target is not a
319  data frame. This fixes an issue where `POSIXlt` objects would carry
320  a `row.names` attribute after a proxy/restore roundtrip.
321
322* `vec_cast()` to and from data frames preserves the row names of
323  inputs.
324
325* The internal function `vec_names()` now returns row names if the
326  input is a data frame. Similarly, `vec_set_names()` sets row names
327  on data frames. This is part of a general effort at making row names
328  the vector names of data frames in vctrs.
329
330  If necessary, the row names are repaired verbosely but without error
331  to make them unique. This should be a mostly harmless change for
332  users, but it could break unit tests in packages if they make
333  assumptions about the row names.
334
335
336## Compatibility and fallbacks
337
338* With the double dispatch changes, the coercion methods are no longer
339  inherited from parent classes. This is because the coercion
340  hierarchy is in principle different from the S3 hierarchy. A
341  consequence of this change is that subclasses that don't implement
342  coercion methods are now in principle incompatible.
343
344  This is particularly problematic with subclasses of data frames for
345  which throwing incompatible errors would be too incovenient for
346  users. To work around this, we have implemented a fallback to the
347  relevant base data frame class (either `data.frame` or `tbl_df`) in
348  coercion methods (#981). This fallback is silent unless you set the
349  `vctrs:::warn_on_fallback` option to `TRUE`.
350
351  In the future we may extend this fallback principle to other base
352  types when they are explicitly included in the class vector (such as
353  `"list"`).
354
355* Improved support for foreign classes in the combining operations
356  `vec_c()`, `vec_rbind()`, and `vec_unchop()`. A foreign class is a
357  class that doesn't implement `vec_ptype2()`. When all the objects to
358  combine have the same foreign class, one of these fallbacks is invoked:
359
360  -  If the class implements a `base::c()` method, the method is used
361    for the combination. (FIXME: `vec_rbind()` currently doesn't use
362    this fallback.)
363
364  - Otherwise if the objects have identical attributes and the same
365    base type, we consider them to be compatible. The vectors are
366    concatenated and the attributes are restored (#776).
367
368  These fallbacks do not make your class completely compatible with
369  vctrs-powered packages, but they should help in many simple cases.
370
371* `vec_c()` and `vec_unchop()` now fall back to `base::c()` for S4 objects if
372  the object doesn't implement `vec_ptype2()` but sets an S4 `c()`
373  method (#919).
374
375
376## Vector operations
377
378* `vec_rbind()` and `vec_c()` with data frame inputs now consistently
379  preserve the names of list-columns, df-columns, and matrix-columns
380  (#689). This can cause some false positives in unit tests, if they
381  are sensitive to internal names (#1007).
382
383* `vec_rbind()` now repairs row names silently to avoid confusing
384  messages when the row names are not informative and were not created
385  on purpose.
386
387* `vec_rbind()` gains option to treat input names as row names. This
388  is disabled by default (#966).
389
390* New `vec_rep()` and `vec_rep_each()` for repeating an entire vector
391  and elements of a vector, respectively. These two functions provide
392  a clearer interface for the functionality of `vec_repeat()`, which
393  is now deprecated.
394
395* `vec_cbind()` now calls `vec_restore()` on inputs emptied of their
396  columns before computing the common type. This has
397  consequences for data frame classes with special columns that
398  devolve into simpler classes when the columns are subsetted
399  out. These classes are now always simplified by `vec_cbind()`.
400
401  For instance, column-binding a grouped data frame with a data frame
402  now produces a tibble (the simplified class of a grouped data
403  frame).
404
405* `vec_match()` and `vec_in()` gain parameters for argument tags (#944).
406
407* The internal version of `vec_assign()` now has support for assigning
408  names and inner names. For data frames, the names are assigned
409  recursively.
410
411* `vec_assign()` gains `x_arg` and `value_arg` parameters (#918).
412
413* `vec_group_loc()`, which powers `dplyr::group_by()`, now has more
414  efficient vector access (#911).
415
416* `vec_ptype()` gained an `x_arg` argument.
417
418* New `list_sizes()` for computing the size of every element in a list.
419  `list_sizes()` is to `vec_size()` as `lengths()` is to `length()`, except
420  that it only supports lists. Atomic vectors and data frames result in an
421  error.
422
423* `new_data_frame()` infers size from row names when `n = NULL` (#894).
424
425* `vec_c()` now accepts `rlang::zap()` as `.name_spec` input. The
426  returned vector is then always unnamed, and the names do not cause
427  errors when they can't be combined. They are still used to create
428  more informative messages when the inputs have incompatible types (#232).
429
430
431## Classes
432
433* vctrs now supports the `data.table` class. The common type of a data
434  frame and a data table is a data table.
435
436* `new_vctr()` now always appends a base `"list"` class to list `.data` to
437  be compatible with changes to `vec_is_list()`. This affects `new_list_of()`,
438  which now returns an object with a base class of `"list"`.
439
440* dplyr methods are now implemented for `vec_restore()`,
441  `vec_ptype2()`, and `vec_cast()`. The user-visible consequence (and
442  breaking change) is that row-binding a grouped data frame and a data
443  frame or tibble now returns a grouped data frame. It would
444  previously return a tibble.
445
446* The `is.na<-()` method for `vctrs_vctr` now supports numeric and
447  character subscripts to indicate where to insert missing values (#947).
448
449* Improved support for vector-like S4 objects (#550, #551).
450
451* The base classes `AsIs` and `table` have vctrs methods (#904, #906).
452
453* `POSIXlt` and `POSIXct` vectors are handled more consistently (#901).
454
455* Ordered factors that do not have identical levels are now incompatible.
456  They are now incompatible with all factors.
457
458
459## Indexing and names
460
461* `vec_as_subscript()` now fails when the subscript is a matrix or an
462  array, consistently with `vec_as_location()`.
463
464* Improved error messages in `vec_as_location()` when subscript is a
465  matrix or array (#936).
466
467* `vec_as_location2()` properly picks up `subscript_arg`
468  (tidyverse/tibble#735).
469
470* `vec_as_names()` now has more informative error messages when names
471  are not unique (#882).
472
473* `vec_as_names()` gains a `repair_arg` argument that when set will cause
474  `repair = "check_unique"` to generate an informative hint (#692).
475
476
477## Conditions
478
479* `stop_incompatible_type()` now has an `action` argument for customizing
480  whether the coercion error came from `vec_ptype2()` or `vec_cast()`.
481  `stop_incompatible_cast()` is now a thin wrapper around
482  `stop_incompatible_type(action = "convert")`.
483
484* `stop_` functions now take `details` after the dots. This argument
485  can no longer be passed by position.
486
487* Supplying both `details` and `message` to the `stop_` functions is
488  now an internal error.
489
490* `x_arg`, `y_arg`, and `to_arg` are now compulsory arguments in
491  `stop_` functions like `stop_incompatible_type()`.
492
493* Lossy cast errors are now considered internal. Please don't test for
494  the class or explicitly handle them.
495
496* New argument `loss_type` for the experimental function
497  `maybe_lossy_cast()`. It can take the values "precision" or
498  "generality" to indicate in the error message which kind of loss is
499  the error about (double to integer loses precision, character to
500  factor loses generality).
501
502* Coercion and recycling errors are now more consistent.
503
504
505## CRAN results
506
507* Fixed clang-UBSAN error "nan is outside the range of representable
508  values of type 'int'" (#902).
509
510* Fixed compilation of stability vignette following the date
511  conversion changes on R-devel.
512
513
514# vctrs 0.2.4
515
516* Factors and dates methods are now implemented in C for efficiency.
517
518* `new_data_frame()` now correctly updates attributes and supports merging
519  of the `"names"` and `"row.names"` arguments (#883).
520
521* `vec_match()` gains an `na_equal` argument (#718).
522
523* `vec_chop()`'s `indices` argument has been restricted to positive integer
524  vectors. Character and logical subscripts haven't proven useful, and this
525  aligns `vec_chop()` with `vec_unchop()`, for which only positive integer
526  vectors make sense.
527
528* New `vec_unchop()` for combining a list of vectors into a single vector. It
529  is similar to `vec_c()`, but gives greater control over how the elements
530  are placed in the output through the use of a secondary `indices` argument.
531
532* Breaking change: When `.id` is supplied, `vec_rbind()` now creates
533  the identifier column at the start of the data frame rather than at
534  the end.
535
536* `numeric_version` and `package_version` lists are now treated as
537  vectors (#723).
538
539* `vec_slice()` now properly handles symbols and S3 subscripts.
540
541* `vec_as_location()` and `vec_as_subscript()` are now fully
542  implemented in C for efficiency.
543
544* `num_as_location()` gains a new argument, `zero`, for controlling whether
545  to `"remove"`, `"ignore"`, or `"error"` on zero values (#852).
546
547
548# vctrs 0.2.3
549
550* The main feature of this release is considerable performance
551  improvements with factors and dates.
552
553* `vec_c()` now falls back to `base::c()` if the vector doesn't
554  implement `vec_ptype2()` but implements `c()`. This should improve
555  the compatibility of vctrs-based functions with foreign classes
556  (#801).
557
558* `new_data_frame()` is now faster.
559
560* New `vec_is_list()` for detecting if a vector is a list in the vctrs sense.
561  For instance, objects of class `lm` are not lists. In general, classes need
562  to explicitly inherit from `"list"` to be considered as lists by vctrs.
563
564* Unspecified vectors of `NA` can now be assigned into a list (#819).
565
566  ```
567  x <- list(1, 2)
568  vec_slice(x, 1) <- NA
569  x
570  #> [[1]]
571  #> NULL
572  #>
573  #> [[2]]
574  #> 2
575  ```
576
577* `vec_ptype()` now errors on scalar inputs (#807).
578
579* `vec_ptype_finalise()` is now recursive over all data frame types, ensuring
580  that unspecified columns are correctly finalised to logical (#800).
581
582* `vec_ptype()` now correctly handles unspecified columns in data frames, and
583  will always return an unspecified column type (#800).
584
585* `vec_slice()` and `vec_chop()` now work correctly with `bit64::integer64()`
586  objects when an `NA` subscript is supplied. By extension, this means that
587  `vec_init()` now works with these objects as well (#813).
588
589* `vec_rbind()` now binds row names. When named inputs are supplied
590  and `names_to` is `NULL`, the names define row names. If `names_to`
591  is supplied, they are assigned in the column name as before.
592
593* `vec_cbind()` now uses the row names of the first named input.
594
595* The `c()` method for `vctrs_vctr` now throws an error when
596  `recursive` or `use.names` is supplied (#791).
597
598
599# vctrs 0.2.2
600
601* New `vec_as_subscript()` function to cast inputs to the base type
602  of a subscript (logical, numeric, or character). `vec_as_index()`
603  has been renamed to `vec_as_location()`. Use `num_as_location()` if
604  you need more options to control how numeric subscripts are
605  converted to a vector of locations.
606
607* New `vec_as_subscript2()`, `vec_as_location2()`, and
608  `num_as_location2()` variants for validating scalar subscripts and
609  locations (e.g. for indexing with `[[`).
610
611* `vec_as_location()` now preserves names of its inputs if possible.
612
613* `vec_ptype2()` methods for base classes now prevent
614  inheritance. This makes sense because the subtyping graph created by
615  `vec_ptype2()` methods is generally not the same as the inheritance
616  relationships defined by S3 classes. For instance, subclasses are
617  often a richer type than their superclasses, and should often be
618  declared as supertypes (e.g. `vec_ptype2()` should return the
619  subclass).
620
621  We introduced this breaking change in a patch release because
622  `new_vctr()` now adds the base type to the class vector by default,
623  which caused `vec_ptype2()` to dispatch erroneously to the methods
624  for base types. We'll finish switching to this approach in vctrs
625  0.3.0 for the rest of the base S3 classes (dates, data frames, ...).
626
627* `vec_equal_na()` now works with complex vectors.
628
629* `vctrs_vctr` class gains an `as.POSIXlt()` method (#717).
630
631* `vec_is()` now ignores names and row names (#707).
632
633* `vec_slice()` now support Altvec vectors (@jimhester, #696).
634
635* `vec_proxy_equal()` is now applied recursively across the columns of
636  data frames (#641).
637
638* `vec_split()` no longer returns the `val` column as a `list_of`. It is now
639  returned as a bare list (#660).
640
641* Complex numbers are now coercible with integer and double (#564).
642
643* zeallot has been moved from Imports to Suggests, meaning that `%<-%` is no
644  longer re-exported from vctrs.
645
646* `vec_equal()` no longer propagates missing values when comparing list
647  elements. This means that `vec_equal(list(NULL), list(NULL))` will continue to
648  return `NA` because `NULL` is the missing element for a list, but now
649  `vec_equal(list(NA), list(NA))` returns `TRUE` because the `NA` values are
650  compared directly without checking for missingness.
651
652* Lists of expressions are now supported in `vec_equal()` and functions that
653  compare elements, such as `vec_unique()` and `vec_match()`. This ensures that
654  they work with the result of modeling functions like `glm()` and `mgcv::gam()`
655  which store "family" objects containing expressions (#643).
656
657* `new_vctr()` gains an experimental `inherit_base_type` argument
658  which determines whether or not the class of the underlying type
659  will be included in the class.
660
661* `list_of()` now inherits explicitly from "list" (#593).
662
663* `vec_ptype()` has relaxed default behaviour for base types; now if two
664  vectors both inherit from (e.g.) "character", the common type is also
665  "character" (#497).
666
667* `vec_equal()` now correctly treats `NULL` as the missing value element for
668  lists (#653).
669
670* `vec_cast()` now casts data frames to lists rowwise, i.e. to a list of
671  data frames of size 1. This preserves the invariant of
672  `vec_size(vec_cast(x, to)) == vec_size(x)` (#639).
673
674* Positive and negative 0 are now considered equivalent by all functions that
675  check for equality or uniqueness (#637).
676
677* New experimental functions `vec_group_rle()` for returning run
678  length encoded groups; `vec_group_id()` for constructing group
679  identifiers from a vector; `vec_group_loc()` for computing the
680  locations of unique groups in a vector (#514).
681
682* New `vec_chop()` for repeatedly slicing a vector. It efficiently captures
683  the pattern of `map(indices, vec_slice, x = x)`.
684
685* Support for multiple character encodings has been added to functions that
686  compare elements within a single vector, such as `vec_unique()`, and across
687  multiple vectors, such as `vec_match()`. When multiple encodings are
688  encountered, a translation to UTF-8 is performed before any comparisons are
689  made (#600, #553).
690
691* Equality and ordering methods are now implemented for raw and
692  complex vectors (@romainfrancois).
693
694
695# vctrs 0.2.1
696
697Maintenance release for CRAN checks.
698
699
700# vctrs 0.2.0
701
702With the 0.2.0 release, many vctrs functions have been rewritten with
703native C code to improve performance. Functions like `vec_c()` and
704`vec_rbind()` should now be fast enough to be used in packages. This
705is an ongoing effort, for instance the handling of factors and dates
706has not been rewritten yet. These classes still slow down vctrs
707primitives.
708
709The API in 0.2.0 has been updated, please see a list of breaking
710changes below. vctrs has now graduated from experimental to a maturing
711package.
712Please note that API changes are still planned for future releases,
713for instance `vec_ptype2()` and `vec_cast()` might need to return a
714sentinel instead of failing with an error when there is no common type
715or possible cast.
716
717
718## Breaking changes
719
720* Lossy casts now throw errors of type `vctrs_error_cast_lossy`.
721  Previously these were warnings. You can suppress these errors
722  selectively with `allow_lossy_cast()` to get the partial cast
723  results. To implement your own lossy cast operation, call the new
724  exported function `maybe_lossy_cast()`.
725
726* `vec_c()` now fails when an input is supplied with a name but has
727  internal names or is length > 1:
728
729  ```
730  vec_c(foo = c(a = 1))
731  #> Error: Can't merge the outer name `foo` with a named vector.
732  #> Please supply a `.name_spec` specification.
733
734  vec_c(foo = 1:3)
735  #> Error: Can't merge the outer name `foo` with a vector of length > 1.
736  #> Please supply a `.name_spec` specification.
737  ```
738
739  You can supply a name specification that describes how to combine
740  the external name of the input with its internal names or positions:
741
742  ```
743  # Name spec as glue string:
744  vec_c(foo = c(a = 1), .name_spec = "{outer}_{inner}")
745
746  # Name spec as a function:
747  vec_c(foo = c(a = 1), .name_spec = function(outer, inner) paste(outer, inner, sep = "_"))
748  vec_c(foo = c(a = 1), .name_spec = ~ paste(.x, .y, sep = "_"))
749  ```
750
751* `vec_empty()` has been renamed to `vec_is_empty()`.
752
753* `vec_dim()` and `vec_dims()` are no longer exported.
754
755* `vec_na()` has been renamed to `vec_init()`, as the primary use case
756  is to initialize an output container.
757
758* `vec_slice<-` is now type stable (#140). It always returns the same
759  type as the LHS. If needed, the RHS is cast to the correct type, but
760  only if both inputs are coercible. See examples in `?vec_slice`.
761
762* We have renamed the `type` particle to `ptype`:
763
764  - `vec_type()` => `vec_ptype()`
765  - `vec_type2()` => `vec_ptype2()`
766  - `vec_type_common()` => `vec_ptype_common()`
767
768  Consequently, `vec_ptype()` was renamed to `vec_ptype_show()`.
769
770
771## New features
772
773* New `vec_proxy()` generic. This is the main customisation point in
774  vctrs along with `vec_restore()`. You should only implement it when
775  your type is designed around a non-vector class (atomic vectors,
776  bare lists, data frames). In this case, `vec_proxy()` should return
777  such a vector class. The vctrs operations will be applied on the
778  proxy and `vec_restore()` is called to restore the original
779  representation of your type.
780
781  The most common case where you need to implement `vec_proxy()` is
782  for S3 lists. In vctrs, S3 lists are treated as scalars by
783  default. This way we don't treat objects like model fits as
784  vectors. To prevent vctrs from treating your S3 list as a scalar,
785  unclass it from the `vec_proxy()` method. For instance here is the
786  definition for `list_of`:
787
788  ```
789  #' @export
790  vec_proxy.vctrs_list_of <- function(x) {
791    unclass(x)
792  }
793  ```
794
795  If you inherit from `vctrs_vctr` or `vctrs_rcrd` you don't need to
796  implement `vec_proxy()`.
797
798* `vec_c()`, `vec_rbind()`, and `vec_cbind()` gain a `.name_repair`
799  argument (#227, #229).
800
801* `vec_c()`, `vec_rbind()`, `vec_cbind()`, and all functions relying
802  on `vec_ptype_common()` now have more informative error messages
803  when some of the inputs have nested data frames that are not
804  convergent:
805
806  ```
807  df1 <- tibble(foo = tibble(bar = tibble(x = 1:3, y = letters[1:3])))
808  df2 <- tibble(foo = tibble(bar = tibble(x = 1:3, y = 4:6)))
809
810  vec_rbind(df1, df2)
811  #> Error: No common type for `..1$foo$bar$y` <character> and `..2$foo$bar$y` <integer>.
812  ```
813
814* `vec_cbind()` now turns named data frames to packed columns.
815
816  ```r
817  data <- tibble::tibble(x = 1:3, y = letters[1:3])
818  data <- vec_cbind(data, packed = data)
819  data
820  # A tibble: 3 x 3
821        x y     packed$x $y
822    <int> <chr>    <int> <chr>
823  1     1 a            1 a
824  2     2 b            2 b
825  3     3 c            3 c
826  ```
827
828  Packed data frames are nested in a single column. This makes it
829  possible to access it through a single name:
830
831  ```r
832  data$packed
833  # A tibble: 3 x 2
834        x y
835    <int> <chr>
836  1     1 a
837  2     2 b
838  3     3 c
839  ```
840
841  We are planning to use this syntax more widely in the tidyverse.
842
843* New `vec_is()` function to check whether a vector conforms to a
844  prototype and/or a size. Unlike `vec_assert()`, it doesn't throw
845  errors but returns `TRUE` or `FALSE` (#79).
846
847  Called without a specific type or size, `vec_assert()` tests whether
848  an object is a data vector or a scalar. S3 lists are treated as
849  scalars by default. Implement a `vec_is_vector()` for your class to
850  override this property (or derive from `vctrs_vctr`).
851
852* New `vec_order()` and `vec_sort()` for ordering and sorting
853  generalised vectors.
854
855* New `.names_to` parameter for `vec_rbind()`. If supplied, this
856  should be the name of a column where the names of the inputs are
857  copied. This is similar to the `.id` parameter of
858  `dplyr::bind_rows()`.
859
860* New `vec_seq_along()` and `vec_init_along()` create useful sequences (#189).
861
862* `vec_slice()` now preserves character row names, if present.
863
864* New `vec_split(x, by)` is a generalisation of `split()` that can divide
865  a vector into groups formed by the unique values of another vector. Returns
866  a two-column data frame containing unique values of `by` aligned with
867  matching `x` values (#196).
868
869
870## Other features and bug fixes
871
872* Using classed errors of class `"vctrs_error_assert"` for failed
873  assertions, and of class `"vctrs_error_incompatible"` (with
874  subclasses `_type`, `_cast` and `_op`) for errors on incompatible
875  types (#184).
876
877* Character indexing is now only supported for named objects, an error
878  is raised for unnamed objects (#171).
879
880* Predicate generics now consistently return logical vectors when
881  passed a `vctrs_vctr` class. They used to restore the output to
882  their input type (#251).
883
884* `list_of()` now has an `as.character()` method. It uses
885  `vec_ptype_abbr()` to collapse complex objects into their type
886  representation (tidyverse/tidyr#654).
887
888* New `stop_incompatible_size()` to signal a failure due to mismatched sizes.
889
890* New `validate_list_of()` (#193).
891
892* `vec_arith()` is consistent with base R when combining `difftime`
893  and `date`, with a warning if casts are lossy (#192).
894
895* `vec_c()` and `vec_rbind()` now handle data.frame columns properly
896  (@yutannihilation, #182).
897
898* `vec_cast(x, data.frame())` preserves the number of rows in `x`.
899
900* `vec_equal()` now handles missing values symmetrically (#204).
901
902* `vec_equal_na()` now returns `TRUE` for data frames and records when
903  every component is missing, not when _any_ component is missing
904  (#201).
905
906* `vec_init()` checks input is a vector.
907
908* `vec_proxy_compare()` gains an experimental `relax` argument, which
909  allows data frames to be orderable even if all their columns are not
910  (#210).
911
912* `vec_size()` now works with positive short row names. This fixes
913  issues with data frames created with jsonlite (#220).
914
915* `vec_slice<-` now has a `vec_assign()` alias. Use `vec_assign()`
916  when you don't want to modify the original input.
917
918* `vec_slice()` now calls `vec_restore()` automatically. Unlike the
919  default `[` method from base R, attributes are preserved by default.
920
921* `vec_slice()` can correct slice 0-row data frames (#179).
922
923* New `vec_repeat()` for repeating each element of a vector the same number
924  of times.
925
926* `vec_type2(x, data.frame())` ensures that the returned object has
927  names that are a length-0 character vector.
928