-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2_define_functions.R
46 lines (36 loc) · 2.1 KB
/
2_define_functions.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
36
37
38
39
40
41
42
43
44
45
46
# ---------------------------------------------------------------------------- #
# Define Functions
# Author: Jeremy W. Eberle
# ---------------------------------------------------------------------------- #
# ---------------------------------------------------------------------------- #
# Define version_control() ----
# ---------------------------------------------------------------------------- #
# Define function to check R version, load groundhog package, and return groundhog_day
version_control <- function() {
# Ensure you are using the same version of R used at the time the script was
# written. To install a previous version, go to
# https://cran.r-project.org/bin/windows/base/old/
script_R_version <- "R version 4.0.3 (2020-10-10)"
current_R_version <- R.Version()$version.string
if(current_R_version != script_R_version) {
warning(paste0("This script is based on ", script_R_version,
". You are running ", current_R_version, "."))
}
# Load packages using "groundhog", which installs and loads the most recent
# versions of packages available on the specified date ("groundhog_day"). This
# is important for reproducibility so that everyone running the script is using
# the same versions of packages used at the time the script was written.
# Note that packages may take longer to load the first time you load them with
# "groundhog.library". This is because you may not have the correct versions of
# the packages installed based on the "groundhog_day". After "groundhog.library"
# automatically installs the correct versions alongside other versions you may
# have installed, it will load the packages more quickly.
# If in the process of loading packages with "groundhog.library" for the first
# time the console states that you first need to install "Rtools", follow steps
# here (https://cran.r-project.org/bin/windows/Rtools/) for installing "Rtools"
# and putting "Rtools" on the PATH. Then try loading the packages again.
library(groundhog)
meta.groundhog("2021-07-01")
groundhog_day <- "2021-01-01"
return(groundhog_day)
}