Description Usage Arguments Details Examples
Given a data set, returns a data set that can be used
as newdata
argument in a call to predict
and similar functions.
1 2 3 4 | make_newdata(x, ...)
## Default S3 method:
make_newdata(x, ...)
|
x |
A data frame (or object that inherits from |
... |
Covariate specifications (expressions) that will be evaluated
by looking for variables in |
Depending on the class of x
, mean or modus values will be
used for variables not specified in ellipsis. If x is an object that inherits
from class ped
, useful data set completion will be attempted depending
on variables specified in ellipsis.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | library(dplyr)
iris %>% make_newdata()
iris %>% make_newdata(Sepal.Length=c(5))
iris %>% make_newdata(Sepal.Length=seq_range(Sepal.Length, 3),
Sepal.Width=c(2, 3))
iris %>% make_newdata(Sepal.Length=seq_range(Sepal.Length, 3),
Species=unique(Species), Sepal.Width=c(2, 3))
# mean/modus values of unspecified variables are calculated over whole data
iris %>% make_newdata(Species=unique(Species))
iris %>% group_by(Species) %>% make_newdata()
# You can also pass a part of the data sets as data frame to make_newdata
purrr::cross_df(list(Sepal.Length = c(0, 500, 1000),
Species = c("setosa", "versicolor"))) %>%
make_newdata(x=iris)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.