-
Notifications
You must be signed in to change notification settings - Fork 1
/
_site.R
36 lines (29 loc) · 1.23 KB
/
_site.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## load any libraries needed across website pages
suppressPackageStartupMessages({
library(readr)
library(dplyr)
library(tidyr)
library(stringr)
library(knitr)
})
## brewed vars
study_area <- "Spain"
key <- "gal"
dir_scenario_gh <- "https://raw.githubusercontent.com/OHI-Science/gal/main/region"
## knitr options for all webpages
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
## read in variables if they exist (i.e. don't try for prep repos)
scores_csv <- file.path(dir_scenario_gh, 'scores.csv')
layers_csv <- file.path(dir_scenario_gh, 'layers.csv')
conf_csv <- file.path(dir_scenario_gh, 'conf/goals.csv')
## if statements in case this is an OHI+ prep repo without these files
if (RCurl::url.exists(scores_csv)) scores <- readr::read_csv(scores_csv)
if (RCurl::url.exists(layers_csv)) layers <- readr::read_csv(layers_csv)
if (RCurl::url.exists(conf_csv)) weight <- readr::read_csv(conf_csv) %>%
select(goal, weight)
## save local copy of conf/web/goals.Rmd
conf_goals_rmd <- file.path(dir_scenario_gh, 'conf/web/goals.Rmd')
if (RCurl::url.exists(conf_goals_rmd)) {
conf_goals <- readr::read_lines(conf_goals_rmd)
readr::write_lines(conf_goals, path = 'conf_goals.Rmd', append = FALSE)
}