knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
nlist
is an R package to create and manipulate numeric list (nlist
) objects.
An nlist
is an S3 class list of uniquely named numeric objects.
An numeric object is an integer or double vector, matrix or array.
nlist
objects are the raw data inputs for analytic engines such as JAGS, STAN and TMB.
An nlists
object is a S3 class list of nlist
objects with the same names, dimensionalities and typeofs.
nlists
objects are useful for storing multiple realizations of simulated data sets.
They can be converted to coda::mcmc
and coda::mcmc.list
objects.
numeric
An numeric object is an integer or double vector, matrix or array.
library(nlist) is.numeric(1L) is.numeric(matrix(1:3))
nlist
An nlist
is an S3 class list of uniquely named numeric objects.
It is straightforward to create an new nlist
object.
library(nlist) nlist <- nlist(x = 1, y = matrix(1:9, 3)) nlist
nlists
An nlists
object is a S3 class list of nlist
objects with the same names, dimensionalities and typeofs.
The nchains attribute is used to keep track of the number of chains.
nlists <- nlists( nlist(x = 1, y = matrix(1:9, 3)), nlist(x = -2, y = matrix(2:10, 3)), nlist(x = 10, y = matrix(22:30, 3)), nlist(x = -100, y = matrix(-2:-10, 3)) ) print(nlists)
A data.frame can be coerced to an nlist
object
data <- data.frame( lgl = c(TRUE, NA), dte = as.Date(c("2001-01-02", "2001-01-01")), fac = factor(c("b", "a")) ) as_nlist(data)
And an nlist
objects can be converted to an mcmc
or term_frame
objects (and converted back again)
as_mcmc(nlist) as_term_frame(nlist)
The estimates()
function can be used to aggregate an nlists
object to an nlist
object.
estimates(nlists, fun = mean)
while the tidy()
function treats the values as if they are MCMC samples
and summarises the terms as a tidy tibble.
tidy(nlists, simplify = TRUE)
An nlists
object can be converted to an mcmc.list
object and a term_frame
.
as_mcmc_list(nlists) as_term_frame(nlists)
An nlists
object can have its chains split or collapsed.
split_chains(nlists)
To install the release version from CRAN.
install.packages("nlist")
The website for the release version is at https://poissonconsulting.github.io/nlist/.
To install the development version from GitHub
# install.packages("remotes") remotes::install_github("poissonconsulting/nlist")
or from r-universe.
install.packages("nlist", repos = c("https://poissonconsulting.r-universe.dev", "https://cloud.r-project.org"))
Please report any issues.
Pull requests are always welcome.
Please note that the nlist project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.