R/file.R

Defines functions write_apsimx read_apsimx

Documented in read_apsimx write_apsimx

#' Read APSIMX file
#'
#' @param path The file path or URL to apsimx file
#'
#' @return A list object of apsimx file
#' @export
#'
#' @examples
#' file <- system.file("wheat.apsimx", package = "rapsimng")
#' m <- read_apsimx(file)
read_apsimx <- function(path) {

    jsonlite::read_json(path, simplifyDataFrame = FALSE,
                        simplifyVector = FALSE, simplifyMatrix = FALSE)
}


#' Write APSIMX file
#'
#' @param l the list of apsimx file
#' @param file The file path to apsimx file
#'
#' @return A list object of apsimx file
#' @export
write_apsimx <- function(l, file) {
    jsonlite::write_json(l, file, pretty = TRUE, auto_unbox = TRUE, null = 'null')
}

Try the rapsimng package in your browser

Any scripts or data that you put into this service are public.

rapsimng documentation built on Sept. 9, 2021, 9:07 a.m.