vec_proxy.distribution | R Documentation |
Methods for vec_proxy
and vec_restore
from vctrs in order to include distribution
objects in
tibble
objects.
vec_proxy.distribution(x, ...)
vec_restore.distribution(x, to, ...)
x , to |
Objects inheriting from |
... |
Currently not used. |
The methods for vec_proxy
and
vec_restore
from vctrs are needed so that
distribution
objects can be included as a vector column in
(and extracted from) tibble
data frames.
vec_proxy
simply adds the class data.frame
which is the
actual underlying data structure used by distribution
objects.
This way the number of rows etc. can be correctly determined. Conversely,
vec_restore
strips off the additional data.frame
class and
restores the original distribution
classes. Users typically do not
need to call vec_proxy
and vec_restore
directly.
The vec_proxy
method returns a distribution
object which
additionally inherits of data.frame
while the vec_restore
method
restores the original distribution
classes.
## Poisson GLM for FIFA 2018 goals data
data("FIFA2018", package = "distributions3")
m <- glm(goals ~ difference, data = FIFA2018, family = poisson)
## Predict fitted Poisson distributions for teams with ability differences
## of -1, 0, 1 (out-of-sample) using the new data as a data.frame
nd <- data.frame(difference = -1:1)
nd$dist <- prodist(m, newdata = nd)
nd
## Do the same using the new data as a tibble
library("tibble")
nt <- tibble(difference = -1:1)
nt$dist <- prodist(m, newdata = nt)
nt
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.