-
Notifications
You must be signed in to change notification settings - Fork 0
/
ae-04-rmarkdown.Rmd
134 lines (79 loc) · 5.38 KB
/
ae-04-rmarkdown.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
---
title: "Application Exercise 4"
subtitle: "Research Design Submission"
output: html_document
---
# R Markdown
## Headings
## Markdown text
This is text written in markdown markup language. Markdown is written in **plain text** and produces formatted text. It's an **open format**, a file format with no restrictions, monetary or otherwise that can be fully processed with at least one free/libre/open-source software tool. As opposed to the .docx file format, which is a **proprietary** file format that a company owns and controls.
## Code chunks
Code chunks are added either by using a keyboard shortcut (Windows: Ctrl + Alt + I; MacOS: Cmd + Option + I) or by clicking on the green plus button in the menu bar of this file.
Code is run either by a click on the green play button in the top right corner of the code chunk or by using a keyboard shortcut (Ctrl / Cmd + Enter) to execute code line by line. The code is sent to the Console where it is executed and the result is printed.
**Terminology**
- Assignment Operator: `<-` (Keyboard shortcut: Alt/Option + -)
- Function: `sum()`, `sqrt()`
- Object: Stored in current R session and can be viewed in 'Environment' Tab
## Inline code
You can also write code inline by using the single backtick, followed by the letter r and the code.
## Concept Map
I have included a concept map of R Markdown below [(Copyright (c) RStudio)](https://github.com/rstudio/concept-maps/blob/master/LICENSE.md) under licensed under [CC-BY](http://creativecommons.org/licenses/by/4.0/). You will learn how to use this code to include images as part of the course.
```{r}
knitr::include_graphics("https://raw.githubusercontent.com/rstudio/concept-maps/master/en/rmarkdown.svg")
```
# Exercises
## Exercise 0 - Let git know who you are
1. Edit the details in the following code to your name and email. This is the name and email that your commits will be associated with.
usethis::use_git_config(user.name = "Jane", user.email = "[email protected]")
2. Copy the line of code to your clipboard (Ctrl + C).
3. Paste the line of code in the Console and hit ther Return (Enter) key.
## Exercise 1 - Knit, Add, Commit, Push
1. **Knit:** Render this file to HTML (*Tip: Click the Knit Button at the top of this file*)
2. **Add** Open the Git pane and add all files to the staging area (*Tip: Tick off all checkboxes under column 'Staged'*)
3. **Commit:** Commit pending changes, add a meaningful commit message
4. **Push:** Push changes to the remote repository (i.e. GitHub)
## Exercise 2 - Research Questions + Design
1. Add the research questions that you and/or your group have worked on below. Write a bullet point for each research question and sub-question.
**remove me and write your text here**
2. Write up the research design you are planning to use for your data collection.
**remove me and write your text here**
3. Submit your sample population:
- Bins: (1) Number; (2) Location, (3) Frequency of sampling
- Human population, for example random, over 60, family, cyclist, etc.
You can download a CSV with data on all bins from:
- https://www.ogd.stadt-zuerich.ch/geoportal_download/71dc10de-a5e2-11ec-94cb-005056b0ce82.zip (**valid until 22nd March**)
- https://www.stadt-zuerich.ch/geodaten/download/Abfallgefaesse (**Stadt Zürich Open Data, in German**)
**remove me and write your text here**
4. Write up the variables that are needed, together with the respective questions and possible response values.
**remove me and write your text here**
5. Knit, Add, Commit + Push your changes back to GitHub
## Exercise 2: Each ~~group~~ person will
1. Add the research questions that you and/or your group have worked on.
2. Write up the research design you are planning to use for your data collection.
3. Submit their sample population:
- Bins: (1) Number; (2) Location, (3) Frequency of sampling
- Human population, for example random, over 60, family, cyclist, etc.
4. Write up the variables that are needed, together with the respective questions and possible response values.
## Exercise 3 - Hyperlinks and Equations (**Bonus**)
1. Use an online search engine to find the book "R Markdown: The Definitive Guide" and open it in your browser.
2. Navigate to Section 2.5, read Sections 2.5.1, 2.5.2, and 2.5.3.
3. Use what you have learned to add a hyperlink below.
4. Use what you have learned to add an equation below.
**remove me and add a hyperlink**
**remove me and add an equation**
5. Knit, Add, Commit + Push your changes back to GitHub
## Exercise 4 - Output Options (**Bonus**)
1. Click on the gear icon next to the Knit button
2. Scroll down to 'Output Options...' and click. A new window opens.
3. Under 'General' tab, select to include a table of contents.
4. Under 'General' tab, change the value at 'Apply theme:' from default to a theme of your choice.
5. Click OK to close the options window.
6. Scroll up to the YAML header to see what has changed.
7. Knit, Add, Commit + Push your changes back to GitHub
# Keyboard Shortcuts
Keyboard shortcuts are essential when working with any programming language and we recommend to use from the start instead of using the point + click buttons that are available in RStudio.
- **Add new code chunk:** Ctrl/Cmd + Alt + I
- **Execute code line by line within a code chunk:** Ctrl/Cmd + Enter
- **Execute an entire code chunk:** Ctrl/Cmd + Shift + Enter
- **The Pipe (%>%):** Ctrl/Cmd + Shift + M
- **Assignment operator (<-)**: Alt/Option + -