R/setOption.R

#########################################################################/**
# @RdocDefault setOption
#
# @title "Sets a option in R"
#
# \description{
#  @get "title" by specifying its name as a @character string.
# }
#
# @synopsis
#
# \arguments{
#   \item{x}{The name of the option to be set.}
#   \item{value}{The new value of the option.}
#   \item{...}{Not used.}
# }
#
# \value{
#   Returns (invisibly) the previous value of the option.
# }
#
# @author
#
# \seealso{
#  See @see "base::getOption" and "base::options".
# }
#
# @keyword "programming"
#*/######################################################################### 
setMethodS3("setOption", "default", function(x, value, ...) {
  # Get the old option value
  ovalue <- getOption(x)

  # Set the new one
  opts <- list(value)
  names(opts) <- x
  options(opts)

  invisible(ovalue)
}) # setOption()

Try the R.utils package in your browser

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

R.utils documentation built on Nov. 18, 2023, 1:09 a.m.