class: center, middle, hide-logo <style type="text/css"> pre { background: #F8F8F8; max-width: 100%; overflow-x: scroll; } </style> <style type="text/css"> .center2 { margin: 0; position: absolute; top: 50%; left: 50%; -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } </style> # Writing your Thesis in RMarkdown ## by <img src="GraphicsSlides/Logo RUG hell.png" width="50%" /> ##### Author/Presenter: Mathias Steilen ##### Last updated: _2022-09-20 20:16:51_ --- # Goals for today's session - Obvious ones: - Learn about RMarkdown - Know how to write your thesis in RMarkdown - Less obvious ones: - Know about the magic of knitr (support for other formats and other programming languages) - Learn how to get the best of all worlds (python, R, whatever other language) <br> Bonus: Ready to use template from us! --- # Why not just use Word? Ever found yourself doing this every time you update your code? <br> .center[ <img src="GraphicsSlides/copy-paste-paste.gif" width="50%" /> ] --- # Why not just use Word? When using word, you're decoupling the coding and writing parts of your thesis: .center[ <img src="GraphicsSlides/decoupled.png" width="80%" /> ] --- # Why not just use Word? With RMarkdown, you're coding and writing in the same place. <br> .center[ <img src="GraphicsSlides/coupled.png" width="70%" /> ] --- # Benefits of RMD over Word .center[ <img src="GraphicsSlides/coupled.png" width="40%" /> ] You should use RMD, if - you want to show output from code in your thesis - you want the practical and aesthetic benefits of LaTeX Benefits - no more `CTRL-C` and `CTRL-V` to reflect changes - LaTeX is much less administrative effort for formatting/alignment in larger projects like a thesis --- # Benefits of RMD over Word The work process in Word (for every individual chart): `Change Chart in R -> Write to .png -> Copy into Word -> Align` If you realise you made a mistake in your early data preprocessing, you'll have to do it all over again for all charts every time! -- <br> .center[ <img src="GraphicsSlides/tense-table-smash.gif" width="30%" /> _Depiction of above process, 2022, colourised_ ] --- # Not in RMD! .pull-left[ Writing your code and text in the same place means: **All changes are reflected immediately.** If you made an error in the data preprocessing, just correct the error. End of story. No modifications to the charts are necessary. Why? Because the code is fully executed, all charts are aligned and formatted each time you knit the document. The keyboard stays intact. ] .pull-right[ .center[ <img src="GraphicsSlides/better than you.png" width="100%" /> ] ] --- # RMarkdown [![video](GraphicsSlides/what is rmarkdown.png)](https://vimeo.com/178485416) --- # Your turn Open an RMarkdown file in RStudio: `File -> New File -> RMarkdown -> Give it a title -> Choose output format PDF` Save this document somewhere you'll find it again. You need a LaTeX distribution to make it work. Luckily, R makes it easy for us. Run the following in your console: ```r install.packages("tinytex") tinytex::install_tinytex() ``` Then, let's inspect what we're looking at. --- # How do you write your thesis with this? A program for your thesis needs to fulfil the following points: - Title page - Table of contents - Table of figures - Page numbering - Citations - References - ... RMarkdown does all of this, because you can use raw LaTeX. This is where the magic happens: You can combine your code and the power of LaTeX to generate research papers. --- class: center, middle #### A disclaimer <img src="GraphicsSlides/mcgregor.png" width="50%" /> --- class: center, middle .pull-left[ Fear not. We got you covered with a template: <img src="GraphicsSlides/template thesis.png" width="100%" /> ] -- .pull-right[ Saves you from this: <br> <br> <img src="GraphicsSlides/wojak dark.jpg" width="80%" /> ] --- # Let's take a look Download the template from the [resources](https://rusergroupstgallen.github.io/resources.html) section on our website and extract the main folder from the ZIP folder. .center[ <img src="GraphicsSlides/structure.png" width="60%" /> ] --- # The Parent Document Open `FirstName-LastName-12345678.pdf`. Let's take a look together .center[ <img src="GraphicsSlides/template thesis.png" width="40%" /> ] --- # The Parent Document Open `FirstName-LastName-12345678.rmd`. Let's take a look together <br> .center[ <img src="GraphicsSlides/parent.png" width="100%" /> ] --- # The Parent Document Let's knit it once. Doing this the first time, the LaTeX distribution first installs the necessary packages from the YAML, this takes a few minutes. The next knit will take much less time. --- # The Children .center[ <img src="GraphicsSlides/structure.png" width="70%" /> ] --- # The Children The following chunk in the parent document "pulls in" the information in the child document. Hence, the parent functions as the global hub for knitting, also setting all formatting and applying it equally to all children. <br> ```` ```{r intro, child = 'introduction.rmd'} ``` ```` <br> **Always knit from the parent document.** This takes a little getting used to, but you'll get around to it. --- # Basic tools Open `introduction.rmd` and keep the PDF open. Let's take a look at this together. <br> .center[ <img src="GraphicsSlides/look.png" width="50%" /> ] --- # So let's recap We wanted: - Title page - Table of contents - Table of figures - Page numbering - Citations - References - ... And most importantly: No more manual copying and pasting. --- # That's it for today! We hope this tutorial was useful! Feel free to make use of the template and don't despair if you encounter errors. For further questions, feel free to reach out to us. Make sure to stay updated on our socials and via our website where all resources and dates are also published. <br> .center[ <img src="GraphicsSlides/Logo RUG hell.png" width="60%" /> **[Website](https://rusergroup-sg.ch/) | [Instagram](https://www.instagram.com/rusergroupstgallen/?hl=en) | [Twitter](https://twitter.com/rusergroupsg)** ] --- class: middle, inverse, hide-logo # Thank you for attending!
The material provided in this presentation including any information, tools, features, content and any images incorporated in the presentation, is solely for your lawful, personal, private use. You may not modify, republish, or post anything you obtain from this presentation, including anything you download from our website, unless you first obtain our written consent. You may not engage in systematic retrieval of data or other content from this website. We request that you not create any kind of hyperlink from any other site to ours unless you first obtain our written permission.