knitr::opts_chunk$set( error = TRUE, collapse = TRUE, comment = "#>", out.width = "100%" )
library(testthat) library(jeksterslabRterm) library(jeksterslabRutils) context("Test term_user_lib.")
tmp <- file.path( tempdir(), util_rand_str() ) dir.create(tmp) on.exit( unlink( tmp, recursive = TRUE ) ) fn_renviron <- file.path( tmp, ".Renviron" ) # The library path is set to `{HOME}/R/{PLATFORM}-library/{R.VERSION}` platform <- R.version[["platform"]] major <- R.version[["major"]] minor <- sub( pattern = "^(\\d+)\\.\\d+$", replacement = "\\1", x = R.version[["minor"]] ) version <- paste0( major, ".", minor ) libpath <- file.path( Sys.getenv("HOME"), "R", paste0( platform ), version ) init <- dir.exists(libpath)
term_user_lib( dir = tmp )
test_that(".Renviron", { expect_true( file.exists(fn_renviron) ) })
unlink( c( fn_renviron, tmp ), recursive = TRUE ) if (!init) { unlink( libpath, recursive = TRUE ) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.