-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rprofile
35 lines (26 loc) · 1.06 KB
/
.Rprofile
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
## Print this on start so I know it's loaded.
cat("Loading custom .Rprofile \n")
## Nice option for local work. I keep it commented out so my code can remain portable.
options(stringsAsFactors = FALSE)
## Increase the size of my Rhistory file, becasue I like to use the up arrow!
Sys.setenv(R_HISTSIZE='100000')
# `local` creates a new, empty environment
# This avoids polluting .GlobalEnv with the object r
local({
r = getOption("repos")
r["CRAN"] = "https://cran.rstudio.com/"
options(repos = r)
})
## Load basic packages automatically
# if (!require("pacman")) install.packages("pacman")
# pacman::p_load(dplyr, ggplot2, lubridate, readr, stringr, tidyr, doParallel)
## Create invisible environment ot hold all your custom functions
.env <- new.env()
## Single character shortcuts for summary() and head().
.env$s <- base::summary
.env$h <- utils::head
.env$v <- utils::View
#ht==headtail, i.e., show the first and last 10 items of an object.
.env$ht <- function(d, n = 6) rbind(head(d, n), tail(d, n))
## Attach all the variables above
attach(.env)