-
Notifications
You must be signed in to change notification settings - Fork 65
/
00-vocabulary.Rmd
133 lines (103 loc) · 2.21 KB
/
00-vocabulary.Rmd
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Vocabulary
To quote Hadley Wickham from his excellent book *Advanced R* <http://adv-r.had.co.nz/Vocabulary.html>:
"An important part of being fluent in R is having a good working vocabulary. [...] I have listed the functions that I believe constitute such a vocabulary. You don't need to be intimately familiar with the details of every function, but you should at least be aware that they all exist. If there are functions in this list that you've never heard of, I strongly recommend that you read their documentation."
I encourage you to look through Hadley's full list at the link above.
Below, I have reduced Hadley's list to those most relevant to this workshop. It will help you follow the material if you are at least somewhat aware of the following functions and their purpose.
## The basics
```{r, eval = FALSE}
# The first functions to learn
?
str
# Important operators and assignment
%in%
$, [, [[, head, tail, subset
# Comparison
!=, ==, >, >=, <, <=
is.na
# Basic math
*, +, -, /, ^
abs
ceiling, floor, round
exp, log, log10, log2, sqrt
max, min, prod, sum
range
mean, median, cor, sd, var
# Logical & sets
&, |, !, xor
all, any
which
# Vectors and matrices
c, matrix
length, dim, ncol, nrow
cbind, rbind
names, colnames, rownames
# Making vectors
c
rep, rep_len
seq, seq_len, seq_along
rev
sample
(is/as).(character/numeric/logical/...)
# Lists & data.frames
list
data.frame, as.data.frame
expand.grid
# Control flow
if
for, while
ifelse
# Apply & friends
lapply, sapply
```
## Common data structures
```{r, eval = FALSE}
# Date time
library(lubridate)
# Character manipulation
grep
gsub
strsplit
tolower, toupper
substr
paste, paste0
# Factors
factor, levels
reorder, relevel
findInterval
```
## Statistics
```{r, eval = FALSE}
# Ordering and tabulating
duplicated, unique
quantile
sort
# Linear models
fitted, predict, resid
lm, glm
I
anova, coef, confint
# Random variables
rnorm, rlnorm, plogis, qlogis, ...
```
## Working with R
```{r, eval = FALSE}
# Workspace
ls, exists, rm
getwd, setwd
source
install.packages, library
# Help
help, ?
citation
example
vignette
```
## I/O
```{r, eval = FALSE}
# Reading and writing data
data
read.csv, write.csv
readLines, writeLines
readRDS, saveRDS
load, save
```