R/generate_data.R
genDataDensity.Rd
Data are generated from an a density defined by a vector of integers
genDataDensity(n, dataDist, varname, uselimits = FALSE, id = "id")
Number of samples to draw from the density.
Vector that defines the desired density
Name of variable name
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.
A string specifying the field that serves as the record id. The default field is "id".
A data table with the generated data
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")
#> Key: <id>
#> id x1
#> <int> <num>
#> 1: 1 -0.5694137
#> 2: 2 4.0542217
#> 3: 3 7.6214794
#> 4: 4 5.7418883
#> 5: 5 8.5160695
#> ---
#> 496: 496 9.3678336
#> 497: 497 4.6014444
#> 498: 498 3.8036096
#> 499: 499 5.1058410
#> 500: 500 9.3376967
genDataDensity(500, data_dist, varname = "x1", uselimits = TRUE, id = "id")
#> Key: <id>
#> id x1
#> <int> <num>
#> 1: 1 4.790279
#> 2: 2 3.189019
#> 3: 3 7.262826
#> 4: 4 6.379838
#> 5: 5 5.273627
#> ---
#> 496: 496 7.036904
#> 497: 497 5.153915
#> 498: 498 4.036004
#> 499: 499 8.700270
#> 500: 500 9.034203