Simulate Data from R or 'JAGS' Code

Generates data from R or 'JAGS' code for use in simulation studies. The data are returned as an 'nlist::nlists' object and/or saved to file as individual '.rds' files. Parallelization is implemented using the 'future' package. Progress is reported using the 'progressr' package.


sims

Lifecycle:stable R-CMD-check Codecov License:MIT CRANstatus CRAN downloads

sims is an R package to generate datasets from R or JAGS code for use in simulation studies. The datasets are returned as an nlists object and/or saved to file as individual .rds files. Parallelization is implemented using the future package. Progress is reported using the progressr package.

Installation

You can install the released version of sims from CRAN with:

install.packages("sims")

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("audrey-b/sims")

Demonstration

Simulate Data

By default, sims_simulate() returns the simulated datasets in the form of an nlists object.

library(sims)
set.seed(10)
sims_simulate("a <- runif(1)", nsims = 2L)
#> $a
#> [1] 0.2213763
#> 
#> an nlists object of 2 nlist objects each with 1 numeric element

If, however, save = TRUE then each nlist object is saved as an .rds file in path.

set.seed(10)
sims_simulate("a <- runif(1)", nsims = 2L, save = TRUE, path = tempdir(), exists = NA, ask = FALSE)
#> [1] TRUE
sims_data_files(tempdir())
#> [1] "data0000001.rds" "data0000002.rds"
sims_data(tempdir())
#> $a
#> [1] 0.2213763
#> 
#> an nlists object of 2 nlist objects each with 1 numeric element

Contribution

Please report any issues.

Pull requests are always welcome.

Code of Conduct

Please note that the sims project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("sims")

0.0.5 by Audrey Beliveau, a month ago


https://github.com/audrey-b/sims


Report a bug at https://github.com/audrey-b/sims/issues


Browse source code at https://github.com/cran/sims


Authors: Audrey Beliveau [aut, cre] , Joe Thorley [aut]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports chk, future.apply, nlist, parallel, stats, yesno

Suggests covr, future, knitr, progressr, rjags, rmarkdown, spelling, testthat, withr

System requirements: JAGS 4.x.y


See at CRAN