R interface to the libcbm carbon budget model library and CBM-EXN model based on CBM-CFS3.
CBM-EXN is a CBM-CFS3 equivalent model driven by net C increments.
# install.packages("devtools")
# devtools::install_dev_deps()
devtools::install("~/GitHub/libcbmr") ## source package directory
# install.packages("remotes")
# remotes::install_github("PredictiveEcology/libcbmr")
install.packages("libcbmr", repos = c('https://predictiveecology.r-universe.dev', 'https://cloud.r-project.org'))
Users on NRCAN machines may need to configure the use of the NRCAN root certificate in order to resolve SSL issues accessing HTTPS sites from R and python.
REQUESTS_CA_BUNDLE environment variableUse either of the approaches below (not both) to set the variable for all R sessions or system-wide.
Use usethis::edit_r_environ("user") to edit your user's .Renviron file.
Add the following (using the actual path to the certificate file):
REQUESTS_CA_BUNDLE='/path/to/NRCAN-RootCA'
Setting this system-wide will affect all programs, not just R.
REQUESTS_CA_BUNDLE and set its value to the full file path of the certificate you downloaded.libcbmr installation and configurationUse one of the installation methods below.
NOTE: the full installation path cannot contain spaces, e.g. in your Windows user name.
## install python
library(reticulate)
condaVersion <- tryCatch(conda_version(conda = "auto"),
error = function(e) NA_character_)
if (is.na(condaVersion)) {
reticulate::install_miniconda() ## full path cannot contain spaces!
conda_create("r-reticulate")
}
## install libcbm (python package)
library(libcbmr)
envname <- "r-reticulate" ## default used by reticulate
install_libcbm(method = "conda", envname = envname)
## install python
library(reticulate)
# pypath <- install_python(version = "3.11:latest")
## instead of using reticulate to install python,
## install manually from https://www.python.org/downloads/
## make note of the install location
pypath <- Sys.which("python")
envname <- "r-reticulate" ## default used by reticulate
envpath <- reticulate:::virtualenv_path(envname)
if (!dir.exists(envpath)) {
dir.create(envpath, recursive = TRUE)
}
virtualenv_create(envname, pypath)
library(libcbmr)
install_libcbm(method = "virtualenv", envname = envname)
libcbmr
library(reticulate)
library(libcbmr)
py_use_env(envname)