R/saveload.R

Defines functions gp_load gp_save

Documented in gp_load gp_save

#' Save and load a GP model
#'
#' Convenience functions for saving and loading GP models.
#'
#' @name gp_saveload
#'
#' @param gp The gp model object to be saved.
#' @param filename Where to save or load from.
#'
#' @return \code{gp_load} returns the loaded GP model object.
#'
#' @examples
#'
#  # init the model
#' gp <- gp_init()
#' 
#' # fit the model (skipped here)
#' 
#' # save the model
#' filename <- file.path(tempdir(), 'gp.rda')
#' gp_save(gp, filename)
#' 
#' # load the model and remove the file
#' gp <- gp_load(filename)
#' file.remove(filename)
#' 
#'
NULL

#' @rdname gp_saveload
#' @export
gp_save <- function(gp, filename) {
  save(gp, file = filename)
}

#' @rdname gp_saveload
#' @export
gp_load <- function(filename) {
  model <- load(filename)
  get(model)
}

Try the gplite package in your browser

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

gplite documentation built on Aug. 24, 2022, 9:07 a.m.