-
Notifications
You must be signed in to change notification settings - Fork 25
/
02-workshop_projects.Rmd
163 lines (107 loc) · 3.36 KB
/
02-workshop_projects.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
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
---
title: "Using R Studio Projects"
subtitle: "Session 2"
institute: "NHS-R Community"
output:
xaringan::moon_reader:
css:
- default
- css/nhsr.css
- css/nhsr-fonts.css
lib_dir: libs
seal: false
self_contained: true
nature:
highlightStyle: googlecode
highlightLines: true
highlightLanguage: ["r"]
countIncrementalSlides: false
ratio: "16:9"
includes:
after_body: [css/insert-logo.html]
---
```{r libs, include=FALSE}
library(knitr)
library(tidyverse)
library(xaringan)
library(icons)
library(xaringanExtra)
xaringanExtra::use_share_again() # need to get the slide button on html view
opts_chunk$set(
echo = FALSE,
eval = FALSE,
message = FALSE,
warning = FALSE,
fig.width = 7.252,
fig.height = 4,
dpi = 300,
dev.args = list(type = "cairo")
)
```
class: title-slide, left, bottom
<img src="img/session02/cracked_setwd.PNG" width="40%"/>
# `r rmarkdown::metadata$title`
----
## **`r rmarkdown::metadata$subtitle`**
### `r rmarkdown::metadata$author`
### `r rmarkdown::metadata$date`
.right-column[
.footnote[Artwork by @allison_horst]
]
---
# Working Directory
If you tell R/R Studio to look for a file, or save a plot, it will (by default) look in a place called the working
directory (wd)
<img class="center" src="img/session02/working-directory.PNG"/>
You can (usually) see your working directory path at the top of the console panel...
... it often defaults to the "Documents" folder.
This example is ~/workshop-r/ and ~ is in Documents
---
# Browsing in RStudio
If you click the arrow next to the file pathway ~/workshop-r/
<img src="img/session02/working-directory.PNG"/>
it will return you to the working directory and you can see all the files in that folder:
<img class="center" src="img/session02/wd-files.PNG"/>
---
class: center, middle
# Organisation
<img class="center"src="img/session02/cognitive-load.PNG" width="15%"/>
Sooner or later (but probably sooner) you will wish to change where files are saved (and loaded from).
Being organised is key:
Reduces cognitive load (and frustration).
.footnote[Artwork by @allison_horst]
---
# RStudio Projects
make it *far easier* for you to:
1) .blue[*Organise*] files and workflow
2) .blue[*Switch*] between projects
3) .blue[*Share*] scripts / projects with others
.green[(when collaborating or getting assistance)]
Recommended for all tasks (large or small).
---
# Create a project
File `r icons::fontawesome("arrow-right")` New Project `r icons::fontawesome("arrow-right")` New Directory `r icons::fontawesome("arrow-right")` New Project
Name the directory "workshop-r"
Create as a subdirectory somewhere useful for you
Create project!
---
# RStudio Projects
Now your working directory is your project directory:
<img class="center" src="img/session02/workshop-r-project.PNG"/>
R will save and load files from here (by default).
If starting another project, repeat this process.
---
class: middle, center
# R Studio Projects
Switching between projects is simple
<img class="center" src="img/session02/project-list.PNG"/>
---
# Acknowledgements
Artwork by @allison_horst
#### This work is licensed as
Creative Commons
Attribution
ShareAlike 4.0
International
To view a copy of this license, visit
https://creativecommons.org/licenses/by/4.0/