Learn R Programming

rbi (version 0.9.1)

bi_write: Create (init or observation) files for LibBi

Description

This function creates a NetCDF file for LibBi from the given list of vectors and/or data frames. Since any files can be passed to libbi directly via the init, input and obs options, this is mostly used internally, this is mostly used internally.

Usage

bi_write(filename, variables, timed, ...)

Arguments

filename

a path to a NetCDF file to write the variables into, which will be overwritten if it already exists. If necessary, ".nc" will be added to the file name

variables

a list object, the names of which should be the variable names and values should be either single values or data frames

timed

if TRUE, any elements of variables that are vectors will be assumed to have a time dimension

...

arguments passed to netcdf_create_from_list

Value

None, but creates a NetCDF file at the specified path.

Examples

Run this code
# NOT RUN {
filename <- tempfile(pattern="dummy", fileext=".nc")
a <- 3
b <- c(1, 3, 6)
c <- data.frame(dim_a = rep(1:3, time = 2), dim_c = rep(1:2, each = 3), value = 1:6)
variables <- list(a=a, b=b, c=c)
bi_write(filename, variables)
bi_file_summary(filename)
# }

Run the code above in your browser using DataLab