View source: R/generate_synthetic_object.r
generate_synthetic_object | R Documentation |
One way of creating synthetic data is replicating sampling distribution of the variable. This function can be applied to dataframes, numeric or character/factor vectors and obtain an object of equal length with synthetic values.
generate_synthetic_object(obj, seed = NULL, n_news = NULL)
## Default S3 method:
generate_synthetic_object(obj, seed = NULL, n_news = NULL)
## S3 method for class 'numeric'
generate_synthetic_object(obj, seed = NULL, n_news = NULL)
## S3 method for class 'data.frame'
generate_synthetic_object(obj, seed = NULL, n_news = NULL)
obj |
A dataframe, numeric vector or character/factor vector. |
seed |
Specify seed when replication is desired. |
n_news |
Length of the new vectors. By default, same length as input. |
An object of equal dimensions (if n_news
is not specified) with synthetic values.
generate_synthetic_object(mtcars)
generate_synthetic_object(mtcars$mpg)
generate_synthetic_object(as.factor(mtcars$cyl))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.