-
Notifications
You must be signed in to change notification settings - Fork 2
/
RLadiesRmd.html
229 lines (171 loc) · 7.49 KB
/
RLadiesRmd.html
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html>
<head>
<title>RLadiesRmd</title>
<meta charset="utf-8">
<meta name="author" content="Tanja" />
<link href="libs/remark-css/default.css" rel="stylesheet" />
<link rel="stylesheet" href="css/ohsu.css" type="text/css" />
<link rel="stylesheet" href="css/ohsu-fonts.css" type="text/css" />
</head>
<body>
<textarea id="source">
class: center, middle, inverse, title-slide
# RLadiesRmd
### Tanja
### 20/06/2018
---
background-image: url(https://upload.wikimedia.org/wikipedia/commons/c/c1/Rlogo.png)
???
Image credit: [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Rlogo.png)
---
#R Markdown 💻📊📈📃
Enables you to:
- save and execute code and display its output
- create high quality reports that could include [LaTeX](https://www.latex-project.org/) equations
[R Markdown](https://rmarkdown.rstudio.com/) documents are fully reproducable and support many static and dynamic output formts, to name a few: PDF, HTML, MS Word, Beamer...
It is a variant of [Markdown](https://daringfireball.net/projects/markdown/) that has embedded **R code chunks** (denoted by three backticks), to be used with [knitr](https://yihui.name/knitr/) to make it easy to create reproducible web-based reports.
To use **R Markdown** you will need to install package from [CRAN](https://cran.r-project.org/) and load it with:
```r
install.packages("rmakdown",repos = "http://cran.us.r-project.org")
suppressPackageStartupMessages(library(rmarkdown))
```
---
class: middle
<img src="RMarkdown.png" width="1000px" />
You would deffinitely find usefull the following:
- [The R Markdown Cheatsheet](https://ntaback.github.io/UofT_STA130/rmarkdown-2.0.pdf)
- [The R Markdown Reference Guide](https://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf)
---
#Starting with RMarkdown
**<span style="color:red">Task 1</span>:**
Open the file `RMarkdown_Intro.Rmd`
- Change the title of the Markdown Document from `My First Markdown Document` to `RMarkdown Introduction`.
- Click the **"Knit"** button to see the compiled version of your sample code.
---
class: inverse, center, middle
##Congratulations! You’ve just Knitted your `\(1^{st}\)` Rmd document!!!! 👍😃
<img src="kramer_congrats.gif" width="300px" />
---
## Basic Text editing
**<span style="color:red">Task 2</span>:**
Let’s formatted this document further by
- Changing the author of the document to your own name.
- Rewriting the first sentence of the document to say "This is my first R Markdown document."
- Recompiling the document so you can see your changes.
---
##Adding a link
You can turn a word into a link by surrounding it in **hard brackets: [ ]** and then placing the link behind it in **parentheses: ( )**, like this:
[RStudio] (www.rstudio.com)
**<span style="color:red">Task 3</span>:**
Make GitHub in the following paragraph link to https://github.com/RLadiesBelgrade/RL_IntroRmd
---
#Text formatting
To embed formatting instructions into your document using Markdown, you
would surround text by:
- one asterisks to make it italic: *italic*;
- two asterisks to make it bold: **bold** and
- backticks to make it monospaced: `monospaced`.
To make an ordered list you need to place each item on a new line after a
number followed by a period followed by a space:
1. order list
2. item 2
Note that you need to place a blank line between the list and any paragraphs
that come before it.
---
##**<span style="color:red">Task 4</span>:**
- Make the following paragraph in your Rmd document look like this:
The variables can be one of two broad types:
1) **Attribute variable**: has its outcomes described in terms of its characteristics or
attributes;
2) **Measured variable**: has the resulting outcome expressed in numerical terms.
- Make word Knit in the following paragraph bold.
---
#Embeding the `R` code
To embed an R code chunk you would use three back ticks:
` ```{r} `
` chunk of code`
` ``` `
**<span style="color:red">Task 5</span>**: Replace the `cars` data set with the `gapminder` data set.
You can also embed plots by setting `echo = FALSE` to the code chunk to
prevent printing of the R code that generates the plot:
` ```{r, echo=FALSE} `
` chunk of code`
` ``` `
---
**<span style="color:red">Task 6</span>**: Replace the base boxplot of mpg vs. cyl by a ggplot's boxplot to examine a relationship between `continent` and `lifeExp` (remember to use some of the `dplyr` functions too!).
```r
{r gapminder_boxplot, echo=FALSE, warnings=FALSE, message=FALSE}
suppressPackageStartupMessages(library(dplyr))
library(ggplot2)
# ggplot boxplot
ggplot(gapminder, aes(x = continent, y = lifeExp)) +
geom_boxplot(outlier.colour = "hotpink") +
geom_jitter(position = position_jitter(width = 0.1, height = 0), alpha = .2) +
labs (title= "Life Exp. vs. Continent",
x = "Continent", y = "Life Exp.") +
theme(legend.position = "none",
panel.border = element_rect(fill = NA,
colour = "black",
size = .75),
plot.title=element_text(hjust=0.5))
```
---
##Adding **LaTex** equations
Finally, if you wish to add mathematical equations to your Markdown
document you can easily embed LaTeX math equations into your report.
To display equation in its own line it needs to be surrounded by double dollar
symbol `$$` `y = a + bx` `$$`, or to embed an equation in line within the text you
would use only one dollar symbol: `$y = a + bx$`.
**<span style="color:red">Task 7</span>**: Display the equation into it’s own line.
---
class: inverse, center, middle
#Congratulations! You have got the basics to start creating your own fabulous dynamic documents… !!!! 👍😃
<img src="giphy.gif" width="300px" />
---
class: inverse, center, middle
# Thanks!
Please let us get to know you by filling the form:
<https://tatjanakec.shinyapps.io/RLadies_Form/>
[www.datateka.com](www.datateka.com)
[tanjakec.github.io](tanjakec.github.io)
@DataTeka
@Tatjana_Kec
Slides created via the R package [**xaringan**](https://github.com/yihui/xaringan).
The chakra comes from [remark.js](https://remarkjs.com), [**knitr**](http://yihui.name/knitr), and [R Markdown](https://rmarkdown.rstudio.com).
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
<script>var slideshow = remark.create({
"highlightStyle": "atelier-lakeside-light",
"highlightLines": true,
"countIncrementalSlides": false
});
if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
window.dispatchEvent(new Event('resize'));
});
(function() {
var d = document, s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
if (!r) return;
s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
d.head.appendChild(s);
})();</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdn.bootcss.com/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML';
if (location.protocol !== 'file:' && /^https?:/.test(script.src))
script.src = script.src.replace(/^https?:/, '');
document.getElementsByTagName('head')[0].appendChild(script);
})();
</script>
</body>
</html>