.onLoad <- function(libname, pkgname) {
set_computer_name()
set_computer_type()
set_db()
set_border()
invisible()
}
set_computer_name <- function() {
if (file.exists("/tmp/computer")) {
con <- file("/tmp/computer", "r")
name_computer <- readLines(con, n = 1)
close(con)
} else {
name_computer <- "NO_NAME_FOUND"
}
Sys.setenv(COMPUTER = name_computer)
config$name_computer <- name_computer
}
set_computer_type <- function() {
if (config$name_computer %in% config$name_production) {
config$is_production <- TRUE
} else if (config$name_computer %in% config$name_testing) {
config$is_testing <- TRUE
} else {
config$is_dev <- TRUE
}
}
set_db <- function() {
config$db_config <- list(
driver = Sys.getenv("DB_DRIVER", "MySQL"),
server = Sys.getenv("DB_SERVER", "db"),
port = as.integer(Sys.getenv("DB_PORT", 3306)),
user = Sys.getenv("DB_USER", "root"),
password = Sys.getenv("DB_PASSWORD", "example"),
db = Sys.getenv("DB_DB", "sykdomspuls")
)
}
set_border <- function() {
if (config$is_production) {
config$border <- 2020
} else {
config$border <- 2020
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.