2  Portfolio

2.1 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.

2.2 Resources

This week

2.3 Xaringan

🙊 shar-in-gen

  • Install / load the packages
remotes::install_github("yihui/xaringan")
library(xaringanExtra)

2.3.1 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:

2.3.2 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…

Change the preamble to * css: ["xaringan-themer.css"] * highlightStyle: solarized-dark or which ever style you selected.

See the Xaringan CSS Theme Generator site for more details.

2.3.3 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 ---)

2.3.4 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.

2.3.5 Slide sides (e.g. like power point)

.pull-left[To have things on the left]

.pull-right[To have things on the right]

2.3.6 Images

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'}

2.3.7 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}

\[\begin{split} Wetness = 0.1509(B2)+0.1973(B3)\\+0.3279(B4)+0.3406(B8)\\− 0.7112(B11)−0.4572(B12) \end{split}\]

2.3.8 Preview

Load the add In “Infinite Moon Reader” from Yihui Xie generates the slides every time you save the .Rmd. Tools > Addins.

2.3.9 xaringanExtra

xaringanExtra, developed by Garrick Aden-Buie 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

2.4 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:

::: {#CHUNKNAME layout-ncol=2}

![Fig name](FILE){#reference)

![Fig name](FILE){#reference}

:::

Where as in xaringan you might use .pull-left[]

2.5 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

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

2.6 Learning diary

This week for your learning diary you need to create a Xaringan presentation and a your Quarto learning diary.

2.6.1 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.
  • The application criterion will refer to 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.

2.6.2 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.

2.7 Feedback

Was anything that we explained unclear this week or was something really clear…let us know using the feedback form. It’s anonymous and we’ll use the responses to clear any issues up in the future / adapt the material.