-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path2_portfolio.qmd
205 lines (120 loc) · 7.8 KB
/
2_portfolio.qmd
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
# Portfolio {#sec-port}
## Learning outcomes
By the end of this week / the practicals you should be able to:
- Demonstrate appropriate syntax and file structure for Xaringan and Bookdown / Quarto
- Create presentations and books appropriate to the module assignment requirements
- Share your resources online through Git and GitHub
A lot of the concepts have been covered in the lecture (more like a tutorial this week), here some key notes are provided to support and demonstrate the code for creating the slides and book. From using RMarkdown in CASA0005, this should be a little familiar.
## Resources
::: callout-tip
## This week
- [Quarto Quick Start](https://quarto.org/docs/books/#quick-start)
- Grolemund, Y.X., J.J. Allaire, Garrett, 2022. R Markdown: The Definitive Guide.
- Xie, Y., 2022. [With Quarto Coming, is R Markdown Going Away? No. - Yihui Xie | 谢益辉](https://yihui.org/en/2022/04/quarto-r-markdown/ (accessed 1.19.23).
- [xaringan Presentations, Chapter 7](https://bookdown.org/yihui/rmarkdown/xaringan.html)
- Kirenz, J.K., n.d. [Build Presentations in R](https://www.kirenz.com/slides/xaringan-demo-slides.html#1) (accessed 1.5.23).
:::
## Xaringan
`r emo::ji("speak")` shar-in-gen
- Install / load the packages
```{r, eval=FALSE}
remotes::install_github("yihui/xaringan")
library(xaringanExtra)
```
### Template:
`File -> New File -> R Markdown -> From Template -> Ninja Presentation`
The loaded template and lecture had a lot of info, but to get started you need to know the following tools:
### Themes
To change how the RMarkdown renders you can select a different theme...just change the css argument in the preamble...currently it will be...
`css: [default, metropolis, metropolis-fonts]`
To see other themes:
`names(xaringan:::list_css())`
Or, use the package `xaringanthemer`. Simply load the package, have a code chunk at the start of the presentation like this...
```{r xaringan-themer, include=FALSE, echo=TRUE, eval=FALSE}
library(xaringanthemer)
style_solarized_light()
```
Change the preamble to \* `css: ["xaringan-themer.css"]` \* `highlightStyle: solarized-dark` or which ever style you selected.
See the [Xaringan CSS Theme Generator site](https://cran.r-project.org/web/packages/xaringanthemer/vignettes/xaringanthemer.html) for more details.
### Slide controls:
- Add a new slide = `---`
- Add a click to open the next part of a slide = `--`
- Add a flipped slide (colours reversed and message in centre) = class: inverse, center, middle (after the `---`)
### Headings / lists:
- `#`, `##` and so on for sub headings
- Lists use `*` or `1.First item` and `1.Second item`, it will know to list them 1 and then 2.
### Slide sides (e.g. like power point)
`.pull-left[To have things on the left]`
`.pull-right[To have things on the right]`
### Images
```{r echo=FALSE, out.width='60%', fig.align='center', eval=FALSE, echo=TRUE}
knitr::include_graphics('img/Lena-river.jpg')`
```
to control the figure you can specify options within the chunk e.g.
`{r echo=FALSE, out.width='60%', fig.align='center'}`
### Equations
To use an equation it's just placing the values / text in an opening `$$` and closing `$$`e.g.
`$$NDVI= \frac{NIR-Red}{NIR+Red}$$`
You may also want to split equations if they are rather long...with `\begin{split}` and `\\` where you want the splits and then `\end{split}`
```{=tex}
\begin{split}
Wetness = 0.1509(B2)+0.1973(B3)\\+0.3279(B4)+0.3406(B8)\\−
0.7112(B11)−0.4572(B12)
\end{split}
```
### Preview
Load the add In "Infinite Moon Reader" from Yihui Xie generates the slides every time you save the .Rmd. Tools \> Addins.
### xaringanExtra
xaringanExtra, developed by [Garrick Aden-Buie](https://github.com/gadenbuie) is "a playground of enhancements and extensions"..that are easy to add..for example, to add a search function in your slides just add..see [xaringanExtra](https://pkg.garrickadenbuie.com/xaringanExtra/#/search)
```{r xaringanExtra-search, echo=FALSE}
xaringanExtra::use_search(show_icon = TRUE)
```
## Quarto
Quarto allows you to publish Python, R, Julia or Observable in a online book or presentation. To an extent it is an updated `Bookdown` package that the CASA0005 resources were made with, although Bookdown still exists Quarto makes it easier to incorporate different languages and from what i can tel publish to pdf.
Download Quarto: https://quarto.org/
**make sure you have updated RStudio** to at least v2022.02
Next `open a blank RStudio session > New Project > New Directory > Quarto Book`
Two files will open:
- `index.qmd` = the main landing page of the book
- `_quarto.yml` = configuration file
In the `_quarto.yml` file change the details to reflect your workbook, you will notice that the chapters are listed - these reference the other `.qmds` and need to be listed here in order to be rendered in the final book - each `.qmd` is a chapter.
At the bottom there is also the editor argument that can be changed to visual or source code, depending on how you want to edit the contents of each chapter.
Click Render (in the tool bar at the top of the `.qmd`) to see what happens..
The syntax of Quarto, Xaringan and RMarkdown are the same, except you some features are specific to each package...for example..
To have figures side by side in Quarto you'd do:
```{r eval=FALSE, echo=TRUE}
::: {#CHUNKNAME layout-ncol=2}
![Fig name](FILE){#reference)
![Fig name](FILE){#reference}
:::
```
Where as in xaringan you might use `.pull-left[]`
## Git and GitHub
We have seen the use of Git and GitHub in several other modules, so i won't go into it here. For a refresher [read over Git, GitHub and RMarkdown](https://andrewmaclachlan.github.io/CASA0005repo/git-github-and-rmarkdown.html)
**Remember don't upload large files** use .gitignore
Once you have got your project set up with Git and GitHub:
- Render the presentation / book (if using Infinite Moon Reader this will be done for you / if using Quarto you can select render on save)
- Add \> Commit \> Push to GitHub
- On GitHub \> Settings \> Pages the under source
- For Xaringan select `/root`
- For Quarto select `/docs`
The page you are on will then provide a URL
## Learning diary
This week for your learning diary you need to create a Xaringan presentation and a your Quarto learning diary.
### Xaringan
Create a small 9 slide presentation (not including reference slide(s)) and host it on GitHub - place the link in your Quarto portfolio
- Select a sensor of your choice (any)
- Create a short (maximum 9 slide, not including reference slide) presentation on the sensor in xaringan
The presentation will be marked in the same manner set out in mark scheme for the learning diary. Specifically:
- The **summary criterion** will refer to the summary of the sensor you have selected.it will include independent thought
- The **application criterion** will refer to and comment on examples of studies that have used the data from the sensor and their purpose
- The **reflection criterion** will refer to what you have learnt in relation to the sensor, its use and how the data might be used in future work/a broader context.
The code below will embed your Xaringan presentation (URL) into your Quarto learning diary.
```{r, eval=FALSE}
xaringanExtra::embed_xaringan(url = "URL of your presentation",
ratio = "16:9")
```
### Quarto learning diary
The production of the Quarto learning diary is not marked, but it is required for component 2. Once you have made your Quarto document update it with your learning diary entry from week 1, and the Xaringan presentation from week 2.
## Feedback
Was anything that we explained unclear this week or was something really clear...let us know using the [feedback form](https://forms.gle/ArGHKA2sSmN29pVLA). It’s anonymous and we’ll use the responses to clear any issues up in the future / adapt the material.