Learn R Programming

synthesizer (version 0.5.0)

make_synthesizer: Create a function that generates synthetic data

Description

Create a function that accepts a non-negative integer n, and that returns synthetic data sampled from the emperical (multivariate) distribution of x.

Usage

make_synthesizer(x, ...)

# S3 method for numeric make_synthesizer(x, na.rm = FALSE, ...)

# S3 method for integer make_synthesizer(x, na.rm = FALSE, ...)

# S3 method for logical make_synthesizer(x, na.rm = FALSE, ...)

# S3 method for factor make_synthesizer(x, na.rm = FALSE, ...)

# S3 method for character make_synthesizer(x, na.rm = FALSE, ...)

# S3 method for ts make_synthesizer(x, ...)

# S3 method for data.frame make_synthesizer(x, na.rm = FALSE, ...)

Value

A function accepting a single integer argument: the number of synthesized values or records to return. For objects of class

ts

n must be equal to the length of the original data (this is set as the default).

Arguments

x

[vector|data.frame] Template data to be synthesized.

...

arguments passed to other methods

na.rm

[logical] Remove missing values before creating a synthesizer

See Also

Other synthesis: synthesize()

Examples

Run this code
synth <- make_synthesizer(cars$speed)
synth(10)


synth <- make_synthesizer(iris)
synth(6)
synth(150)
synth(250)

Run the code above in your browser using DataLab