forked from CrumpLab/LabJournalWebsite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionary.Rmd
More file actions
202 lines (172 loc) · 4.35 KB
/
Dictionary.Rmd
File metadata and controls
202 lines (172 loc) · 4.35 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
---
title: "Dictionary"
output:
html_document:
toc: true
toc_float: true
collapsed: false
number_sections: false
toc_depth: 1
#code_folding: hide
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(message=FALSE,warning=FALSE, cache=TRUE)
```
### List of functions
General bits
1. help(topic) – search r studio for tips on a function for topic by clicking “Help” on the bottom right panel and performing a search under “Topic”; similar to “?topic”.
2. ?topic - search r studio for tips on a function for topic by typing “?[insert topic name here]” in the Console; similar to “help(topic)”.
3. ls() – shows a list of characters used by the user.
4. dir() – shows a list of files; see list.files().
5. list.files() – shows a list of files; dir().
Input and output
1. save() – saves a data.
2. load() – loads data that was previously saved using “save()”.
3. data() – loads data.
4. library() – downloads packages unto r studio.
5. read.table() – turns data from a file into a table.
6. read.csv() – turns data from a csv into a table.
7. scan() – turns data from a file into a list.
8. print() – returns argument.
9. cat() – turns data into a string and concatenates them, before returning them to the argument.
10. write.table() – turns data into a matrix before returning it to argument and turning it into a file.
Data Creation
1. c() – concatenates variables into a vector.
2. from:to (where from and to are replaced with numbers, e.g. 1:10) – to include numbers “from” to “to” (e.g. to include numbers 1 to 10).
3. seq() – a sequence of number “from” one number “to” another.
4. rep() – repeats a value.
5. data.frame() – a matrix
6. list() – holds list of variables.
7. matrix() – a dataframe.
8. factor() – categorizes a vector as a factor.
9. rbind() – concatenates vectors into a row in a dataframe.
10. cbind() – concatenates vectors into column in a dataframe.
```{r}
```
### Slicing and extracting data
Indexing vectors
1. x[n] nth element
2. x[-n] all but nth element
3. x[1:n] first n elements
4. x[-(1:n)] elements from n+1 to the end
5. x[c(1,4,2)] specific elements
6. x[“name”] elements named “name”
7. x[x>3] all elements greater than 3
8. x[x > 3 & x < 5] all elements between 3 and 5
9. x[x %in% c(“a”,“and”,“the”)] all elements in given set
```{r}
```
### Indexing lists
1. x[n] list with elements n
2. x[[n]] nt h element of the list
3. x[[“name”]] element of the list named “name”
4. x$name id.
```{r}
```
### Indexing matrices
1. x[i,j] element at row i, column j
2. x[i,] row i
3. x[,j] column j
4. x[,c(1,3)] columns 1 and 3
5. x[“name”,] row named “name”
```{r}
```
### Indexing data frames (matrix indexing plus the following)
1. x[[“name”]] column named “name”
2. x$nameid.
```{r}
```
### Variable conversion
1. as.data.frame(x)
2. as.numeric(x)
3. as.logical(x)
4. as.character(x)
```{r}
```
### Variable information
1. is.na(x)
2. is.null(x)
3. is.data.frame(x)
4. is.numeric(x)
5. is.character(x)
6. length(x)
7. dim(x)
8. dimnames(x)
9. nrow(x)
10. ncol(x)
11. class()
12. attributes()
```{r}
```
### Data selection and manipulation
1. which.max()
2. which.min()
3. which()
4. sort()
5. unique()
6. table()
7. sample()
```{r}
```
### Math
1. max()
2. min()
3. range()
4. sum()
5. mean()
6. median()
7. var()
8. sd()
9. cor()
10. round()
11. abs()
```{r}
```
### Matrices
1. t()
2. diag()
3. rowSums()
4. colSums()
5. rowMeans()
6. colMeans()
```{r}
```
### Advanced Data processing
1. apply()
2. aggregate()
```{r}
```
### Strings
1. paste()
2. strsplit()
3. tolower()
4. toupper
```{r}
```
### Plotting
1. hist()
2. plot()
```{r}
```
### Distributions
1. rnorm()
2. runif()
```{r}
```
### Programming
1. show that you can define a function
2. show that you can write a for loop
3. show that you can write a while loop
4. show that you can write an if else statement
5. Explain what return() does inside a function, show you can use it
6. Explain what break() does, show you can use it
```{r}
```
### Installing some packages
Use the packages tab in R-studio to install these packages. You will need to be connected to the internet when you do this. If you are installing on your laptop, or on R-studio Cloud, then these packages will not need to installed again.
1. ggplot2
2. dplyr
3. shiny
4. data.table
5. reshape2
6. stringr