knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Package uniset
provides an easily accessible, user-friendly text file as settings-file for your R-package.
Package uniset
enables any package (the 'target package') to provide its users an easily accessible, user-friendly and human readable text file where key=value pairs (used by functions defined in the target package) can be saved.
This settings file lives in a location defined by the user of the target package, and its user-defined values remain unchanged even when the author of the target package is introducing or deleting keys, or when the target package is updated or re-installed.
In order to enable the target package to make use of the functionality offered by package uniset
, three files have to be exported by uniset
and be placed into the target package.
Install release version from CRAN via
install.packages("uniset")
Or download from github:
install_github(repo="bpollner/uniset", ref="master")
We assume that we want to enable a package called dogPack
to use the dynamic settings file provided by uniset
. In this example, dogPack
is the target package, and we want it to live at ~/desktop
. First copy the example folder dogPack
to your desktop:
library(uniset) to <- path.expand("~/desktop") dsource <- paste0(path.package("uniset"), "/examples/dogPack") file.copy(dsource, to, recursive = TRUE)
There are two ways to set up a target package (in our example the package called dogPack
) to make use of uniset
:
The package name, the name of the setup-function and a location have to be specified, then a call to uniset_getFiles()
creates a folder containing the three required files:
setupFunc <- "dogPack_demo_setup" # the name of the setup-function in our example uniset_getFiles("dogPack", setupFunc, to)
Move files:
'dogPack_settings.R' into the 'inst' folder (create one if not already done) of dogPack
.
'uniset_globals' and 'uniset_functions.R' into the 'R' folder of dogPack
.
A call to uniset_copyFilesToPackage()
copies the three required files directly into the target package -- called dogPack
in our example.
path <- paste0(to, "/dogPack") setupFunc <- "dogPack_demo_setup" # the name of the setup-function in our example uniset_copyFilesToPackage(path, setupFunc)
Please review the file 'dogPackFunc.R' in the folder 'dogPack/R' that was copied to path.expand("~/desktop")
and look at the code of the practical examples that will be executed below.
Go on and read the extended description to deepen your understanding of how uniset
works.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.