Learn R Programming

simstudy (version 0.8.1)

genDataDensity: Generate data from a density defined by a vector of integers

Description

Data are generated from an a density defined by a vector of integers

Usage

genDataDensity(n, dataDist, varname, uselimits = FALSE, id = "id")

Value

A data table with the generated data

Arguments

n

Number of samples to draw from the density.

dataDist

Vector that defines the desired density

varname

Name of variable name

uselimits

Indicator to use minimum and maximum of input data vector as limits for sampling. Defaults to FALSE, in which case a smoothed density that extends beyond the limits is used.

id

A string specifying the field that serves as the record id. The default field is "id".

Examples

Run this code
data_dist <- data_dist <- c(1, 2, 2, 3, 4, 4, 4, 5, 6, 6, 7, 7, 7, 8, 9, 10, 10)

genDataDensity(500, data_dist, varname = "x1", id = "id")
genDataDensity(500, data_dist, varname = "x1", uselimits = TRUE, id = "id")

Run the code above in your browser using DataLab