Skip to content

Instantly share code, notes, and snippets.

@ijlyttle
Last active April 8, 2019 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ijlyttle/dee4a89c8528cd4a0a319bb7b8cdd51a to your computer and use it in GitHub Desktop.
Save ijlyttle/dee4a89c8528cd4a0a319bb7b8cdd51a to your computer and use it in GitHub Desktop.
Generic R setup files
# An .Renviron file helps keep you safe, by storing secrets in one place that
# you can secure.
# - to open *your* .Renviron file, usethis::edit_r_environ()
# - please make sure that your .Renviron file ends with a newline,
# or R will ignore it
# - this is a minimal file, you will likely want to add your own "stuff"
# - if you need to deal with a firewall, this is the place to define
# your proxy variables
#
# More information: https://whattheyforgot.org/r-startup.html#renviron
#
# GitHub PAT (Personal Access Token)
# - helps automate communication between R and GitHub
# - get a PAT by using usethis::browse_github_pat()
# - you will need your GitHub credentials
# - it's up to you if you want to surround the PAT in quotes
# - this PAT will not work; it's here only for demonstration
#
GITHUB_PAT="cf88960e730f6b89f235e45c31101a8319ee4a49"
# An .Rprofile file helps keep you lazy (or undistracted) by setting
# options every time R starts.
# - to open *your* .Rprofile file, usethis::edit_r_profile()
# - please make sure that your .Rprofile file ends with a newline,
# or R will ignore it
# - some things you want to run all the time, others only when you are
# running R interactiveley
# - this is a minimal file, you will likely want to add your own "stuff"
#
# More information: https://whattheyforgot.org/r-startup.html#rprofile
#
# The .First() function can be useful because if you create variables,
# they "stay" in your function, and do not "pollute" your global
# environment.
#
.First <- function() {
# options are used to help define how R "interacts with the world"
# - where to install packages from?
# - how to sign emails?
# - which protocol to use with GitHub?
#
options(
# where does R look when you install.packages()?
repos = c(
# redirects to "best" among worldwide servers, sponsored by RStudio
CRAN = "https://cloud.r-project.org/"
),
# if you submit a package to CRAN using devtools,
# it will send an email on your behalf
# - this the name it uses to sign the email
devtools.name = "Ian Lyttle",
# when you create a package using usethis::create_package(), this
# is used to populate the Author field in the DESCRIPTION file
# - an ORCID can be useful, but it is not mandatory: https://orcid.org/
usethis.description = list(
`Authors@R` = 'person("Ian J", "Lyttle",
email = "ian.lyttle@schneider-electric.com",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9962-4849"))'
),
# depends on your situation to choose ssh or https:
# - https a useful default
# - if you also use GitHub Enterprise, ssh can be useful
usethis.protocol = "https"
)
}
if (interactive()) {
# will load these packages automatically in interactive sessions
suppressMessages(require("devtools"))
suppressMessages(require("usethis"))
suppressMessages(require("testthat"))
suppressMessages(require("reprex"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment