Description Usage Arguments Base methods
This abstract class provides a set of useful default methods that makes it
considerably easier to get started with a new S3 vector class. See
vignette("s3-vector")
to learn how to use it to create your own S3
vector classes.
1 |
.data |
Foundation of class. Must be a vector |
... |
Name-value pairs defining attributes |
class |
Name of subclass. |
inherit_base_type |
\Sexpr[results=rd, stage=render]{vctrs:::lifecycle("experimental")}
Does this class extend the base type of |
The vctr class provides methods for many base generics using a smaller set of generics defined by this package. Generally, you should think carefully before overriding any of the methods that vctrs implements for you as they've been carefully planned to be internally consistent.
[[
and [
use NextMethod()
dispatch to the underlying base function,
then restore attributes with vec_restore()
.
rep()
and length<-
work similarly.
[[<-
and [<-
cast value
to same type as x
, then call
NextMethod()
.
as.logical()
, as.integer()
, as.numeric()
, as.character()
,
as.Date()
and as.POSIXct()
methods call vec_cast()
.
The as.list()
method calls [[
repeatedly, and the as.data.frame()
method uses a standard technique to wrap a vector in a data frame.
as.factor()
, as.ordered()
and as.difftime()
are not generic functions
in base R, but have been reimplemented as generics in the generics
package. vctrs
extends these and calls vec_cast()
. To inherit this
behaviour in a package, import and re-export the generic of interest
from generics
.
==
, !=
, unique()
, anyDuplicated()
, and is.na()
use
vec_proxy()
.
<
, <=
, >=
, >
, min()
, max()
, range()
, median()
,
quantile()
, and xtfrm()
methods use vec_proxy_compare()
.
+
, -
, /
, *
, ^
, %%
, %/%
, !
, &
, and |
operators
use vec_arith()
.
Mathematical operations including the Summary group generics (prod()
,
sum()
, any()
, all()
), the Math group generics (abs()
, sign()
,
etc), mean()
, is.nan()
, is.finite()
, and is.infinite()
use vec_math()
.
dims()
, dims<-
, dimnames()
, dimnames<-
, levels()
, and
levels<-
methods throw errors.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.