| bi_write | R Documentation | 
This function creates (or appends to) 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.
bi_write(
  filename,
  variables,
  append = FALSE,
  overwrite = FALSE,
  time_dim,
  coord_dims,
  dim_factors,
  value_column = "value",
  guess_time = FALSE,
  verbose
)
| 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  | 
| append | if TRUE, will append variables if file exists; default: FALSE | 
| overwrite | if TRUE, will overwrite variables if file exists; default: FALSE | 
| time_dim | the name of the time dimension, if one exists; default: "time" | 
| coord_dims | the names of the coordinate dimension, if any; should be a named list of character vectors, they are matched to variables names | 
| dim_factors | factors that dimensions have; this corresponds to the
 | 
| value_column | if any  | 
| guess_time | whether to guess time dimension; this would be a numerical
column in the data frame given which is not the  | 
| verbose | if TRUE, will print variables as they are read | 
The list of variables must follow the following rules. Each element of the list must itself be one of:
1) a data frame with a value_column column (see option 'value_column')
and any number of other columns indicating one or more dimensions
2) a numeric vector of length one, with no dimensions
The name of the list elements itself is used to create the corresponding variable in the NetCDF file.
A list of the time and coord dims, and factors in extra dimensions, if any
filename <- tempfile(pattern = "dummy", fileext = ".nc")
a <- 3
b <- data.frame(
  dim_a = rep(1:3, time = 2), dim_b = rep(1:2, each = 3), value = 1:6
)
variables <- list(a = a, b = b)
bi_write(filename, variables)
bi_file_summary(filename)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.