This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Close connection to database when app closes | |
cancel.onSessionEnded <- session$onSessionEnded(function() { | |
if(exists("con")){ | |
dbDisconnect(con) | |
print("Connection to DB Closed") | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# UI | |
tags$script( | |
src = paste0( | |
"https://cdn.jsdelivr.net/gh/StephanWagner/", | |
"[email protected]/dist/jBox.all.min.js" | |
) | |
), | |
tags$link( | |
rel = "stylesheet", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set the limits of each axis | |
# these will need to be changed for each data | |
# use summary(df) to get metrics | |
ylim_prime <- c(0.35, 0.76) | |
ylim_sec <- c(6200, 12000) | |
# calculate values for use in plot | |
b <- diff(ylim_prime)/diff(ylim_sec) | |
a <- ylim_prime[1] - b*ylim_sec[1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(requireNamespace("prompt", quietly = T)) { | |
prompt_git <- function(...) { | |
paste0( | |
"[", prompt::prompt_git(), "]", "> " | |
) | |
} | |
prompt::set_prompt(prompt_git) | |
rm(prompt_git) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options(prompt = glue::glue("[git] {crayon::bgRed(crayon::white(as.character(git2r::repository_head())[1]))} >")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For R projects | |
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add fake columns | |
cols_add <- as.character(2020:2039) | |
DT[, (cols_add) := 0] | |
for (col in cols_add) { | |
set(DT, i = 1L, j = col, value = state[1, total] * abs(rnorm(1, mean = 10)) + state[1, total]) | |
set(DT, i = 2L, j = col, value = state[2, total] * abs(rnorm(1)) + state[2, total]) | |
set(DT, i = 3L, j = col, value = state[3, total] * abs(rnorm(1)) + state[3, total]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list.shp <- function(path) { | |
list.files(path, pattern = ".shp$", full.names = T) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat(paste0("export(", gsub(".R$", "", list.files("R")), ")"), sep = "\n") |
NewerOlder