read_rdump: Read data in an R dump file to a list

Description Usage Arguments Details Value See Also Examples

View source: R/misc.R

Description

Create an R list from an R dump file

Usage

1
read_rdump(f, keep.source = FALSE, ...)

Arguments

f

A character string providing the dump file name.

keep.source

logical: should the source formatting be retained when echoing expressions, if possible?

...

passed to source

Details

The R dump file can be read directly by R function source, which by default would read the data into the user's workspace (the global environment). This function instead read the data to a list, making it convenient to prepare data for the stan model-fitting function.

Value

A list containing all the data defined in the dump file with keys corresponding to variable names.

See Also

stan_rdump; dump

Examples

1
2
3
4
x <- 1; y <- 1:10; z <- array(1:10, dim = c(2,5)) 
stan_rdump(ls(pattern = '^[xyz]'), "xyz.Rdump")
l <- read_rdump('xyz.Rdump')
print(l) 

Example output

Loading required package: ggplot2
Loading required package: StanHeaders
rstan (Version 2.16.2, packaged: 2017-07-03 09:24:58 UTC, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
$x
[1] 1

$y
 [1]  1  2  3  4  5  6  7  8  9 10

$z
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    3    5    7    9
[2,]    2    4    6    8   10

rstan documentation built on Nov. 8, 2018, 1:04 a.m.