class: center, middle, inverse, title-slide # Work Smarter, Not Harder ## An Intro To R Markdown
###
Matthew R. Worthington, M.Ed.
###
Resources
###
March 9, 2018
--- --- <style>.green{color: green;}</style> # Do Now: Inefficient Work ## Prompt: * As you come in, grab coffee, some pastries, and find a partner. When you find one, each take no more than three minutes to share an example of a time where you or someone you knew had to accomplish a herculean task *<u>and</u>* you/they: * <u>Had the wrong tools</u>, which made accomplishing that task completely inefficient, arduous, and more painful than you could have ever imagined. And, to this day, you sometimes have night terrors about that experience. * <u>Had the right tools</u> to do that work, which made the work efficient, reasonable, and less burdensome—maybe even enjoyable—than it could have without those tools. ??? #Shareout Activity Ask A Few Folks To Share Their Partner’s Story --- # My Example of Working Efficiently .pull-left[ ## Champ's Meltdown 1. Had A Vet Visit 2. We Left Town * He stayed with sitter 3. Combined Stress made him sick * Resulted in a mess I had to clean-up 4. So, I chose between.... ] .pull-right.center.contain[ ![](images/champ.jpg) ] ??? #My Story: After everyone shares their example, share my example of cleaning up after champ—my dog—when he got sick recently and destroyed our house with explosive diarrhea. --- class: background-image: url(images/poop.jpg) background-size: contain # My Task <div class="my-footer"><span><a href="https://www.facebook.com/jesse.newton.37/posts/776177951574">Image Credit: Jesse Newton 2016</a>                             </span></div> --- class: graphic # My Choices For Cleanup .pull-left[ ## Bissel Spot Cleaner ![](images/spotbot.jpg) ] .pull-right[ ## Rug Doctor Pro ![](images/rugdoctor.jpg) ] --- # Comparing The Tools .pull-left[ ## Bissel Spot Cleaner **Pros** 1. Already owned it 2. Push-button convenience **Cons** 1. Meant for small accidents 2. Inefficient for disasters ] .pull-right[ ## Rug Doctor Pro **Pros** 1. Efficient for disasters **Cons** 1. Had to rent it. .green[
] ] --- class: center, middle, inverse # R Markdown Is The Better Tool <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- # By the end of today, you will: <ul class="fa-ul"> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-check-square"></i>Have R Studio installed, along with the <code>rmarkdown</code> & <code>tinytex</code> packages so you can develop R Markdown projects that knit to PDF, HTML, or Microsoft Word docs.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-square"></i>Know the benefits of using R Markdown compared to traditional productivity tools like Microsoft Office & Google Apps.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-square"></i>Have a general workflow for managing assignments, essays, or other kinds of work with R Studio projects, where R Markdown documents live.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-square"></i>Know the general layout of an R Markdown document, which is composed of three distinct types of text: YAML Headers, Markdown, and Code Chunks.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-square"></i>Successfully knit to a PDF document using R Markdown.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-square"></i>Have a cursory knowledge of how Latex & R Packages enhance what you can do with R Markdown.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-square"></i>Have provided resources for further learning & templates that are relevant to work we do here at LBJ.</li> </ul> --- # Norms For Today -- ## **Reject Intimidation** - Jump in and break stuff -- ## **Embrace Failure** - Read and Google error codes - Ask questions or write them down for later -- ## **Learn New Skills** - Repeat Process --- class:graphic, center, middle <video height="560" controls> <source src="images/books.mp4" type="video/mp4"> </video> --- background-image: url(images/flow.png) background-size: contain # What is R Markdown? <div class="my-footer"><span>Packages used: ggplot2, ggalt, sysfonts, showtext                             </span></div> --- class: center, middle, inverse # What Can R Markdown Do? <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- background-image: url(images/chart1.svg) background-size: contain # Create Amazing Charts <div class="my-footer"><span>Packages used: ggplot2, ggalt, sysfonts, showtext                             </span></div> --- background-image: url(images/ggplot1.png) background-size: contain # Create Amazing Charts <div class="my-footer"><span>Packages used: ggplot2, sysfonts, showtext                             </span></div> --- background-image: url(images/geofacet1.png) background-size: contain # Create Amazing Charts <div class="my-footer"><span>Packages used: ggplot2, geofacet, sysfonts, showtext                             </span></div> --- background-image: url(images/geofacet2.png) background-size: contain # Create Amazing Charts <div class="my-footer"><span>Packages used: ggplot2, geofacet, sysfonts, showtext                             </span></div> --- background-image: url(images/usmap1.png) background-size: contain # GIS Analysis & Visualization <div class="my-footer"><span>Packages used: ggplot2, tidycensus, sf, viridis, sysfonts, showtext                             </span></div> --- background-image: url(images/map1.svg) background-size: contain # GIS Analysis & Visualization <div class="my-footer"><span>Packages used: ggplot2, tidycensus, sf, svglite, cowplot, viridis, sysfonts, showtext                             </span></div> --- background-image: url(images/tidycensus1.png) background-size: contain # GIS Analysis & Visualization <div class="my-footer"><span>Packages used: ggplot2, tidycensus, sf, viridis, sysfonts, showtext                             </span></div> --- background-image: url(images/tidycensus2.png) background-size: contain # GIS Analysis & Visualization <div class="my-footer"><span>Packages used: ggplot2, tidycensus, sf, viridis, sysfonts, showtext                             </span></div> --- background-image: url(images/tidycensus3.png) background-size: contain # GIS Analysis & Visualization <div class="my-footer"><span>Packages used: ggplot2, tidycensus, sf, viridis, sysfonts, showtext                             </span></div> --- background-image: url(images/dotdensity1.png) background-size: contain # GIS Analysis & Visualization <div class="my-footer"><span>Packages used: ggplot2, tidycensus, sf, viridis, sysfonts, showtext                             </span></div> --- class: center, middle # Interactive Tools <iframe src="mapview.html" width="100%" height="100%"></iframe> <div class="my-footer"><span>Packages used: sf, mapview, leaflet, viridis,                             </span></div> --- class: center, middle, inverse # The Benefits of R Markdown <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- # Who Is R Markdown Good For? - Policy Analysts - Data Scientists - Journalists - Publishers - Web Developers - K-12 Teachers - Professors - Researchers --- # What Is R Markdown Good For? - Reproducible Research - Data Analysis - Complex Data Visualizations - GIS Analysis & Visualization - Beautiful Typesetting - Blogging Online - Writing Static & Digital Books - Making Professional Products Easier - i.e. bibliographies, journal formatting (APA vs. Chicago) --- class: center, middle, inverse # Managing Your Work in R Markdown <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- # Organize Everything with R Projects - Create A New “Project” For Every R Markdown Product You Want - Use Files/Folders In Projects To Manage Referenced Materials - Statistical Data - Spatial Data - Images - Bibliographies - Anything Else --- class: center, middle, inverse # Create A New Project & R Markdown Document <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- class:graphic background-image: url(images/rstudioUI.png) background-size: contain --- class: center, middle, inverse # The Basics of R Markdown <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- class: top # The Anatomy of An R Markdown Document ## YAML Headers How you setup your document to produce the kind of output you're looking for. ```yaml --- title: "Regression Analysis" author: "[Your Name]" subtitle: Produced For The Such and Such PRP classoption: twocolumn, titlepage, landscape documentclass: article #others: book, report, memoir fontsize: 11pt #only 10, 11, or 12pt header-includes: - \usepackage[default,light]{sourceserifpro} #loads fonts - \usepackage[T1]{fontenc} #loads font framework output: #<< pdf_document: #defines pdf as my output toc: yes #selects table of content --- ``` --- class: center, middle, inverse # Markdown <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- # The Basics of Markdown ## Headers: Indicated by `#` marks ``` # Header 1 ## Header 2 ### Header 3 #### Header 4 ##### Header 5 ###### Header 6 ``` ## Text Formatting ``` _italics_ __bold__ `code` ``` <div class="my-footer"><span>Credit: @StatGarret                             </span></div> --- # The Basics of Markdown (cont.) ## Bulleted/Unordered Lists ``` - bullet 1 - bullet 2 ``` ## Numbered list ``` 1. item 1 2. item 2 ``` <div class="my-footer"><span>Credit: @StatGarret                             </span></div> --- # The Basics of Markdown (cont.) ## Links ``` This is a [link](https://www.git.com). ``` This is a [link](https://www.git.com). ## Images Images can be inserted by writing: `![Image Caption](images/lbj.png)`, which results in: ![Image Caption](images/lbj.png) <div class="my-footer"><span>Credit: @StatGarret                             </span></div> --- # The Basics of Markdown (cont.) ## Equations Write equations with latex math commands and surround them in $’s. According to Einstein, `$E=mc^{2}$` or `\(E=mc^{2}\)` ## Equation Blocks `$$E=mc^{2}$$` results in a centered equation on its own line. `$$E=mc^{2}$$` <div class="my-footer"><span>Credit: @StatGarret                             </span></div> --- class: center, middle, inverse # Download The Following Document <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> ## <a href='http://tinyurl.com/lbj-rmarkdown-demo' style='color:#fafafa; font-weight:500; margin-left: 256px;' align='center'>tinyurl.com/lbj-rmarkdown-demo</a> --- class: center, middle, inverse # Demo Document Walkthrough <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- class: center, middle, inverse # Going Further With R Markdown <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- # Going Further with R Markdown ## R Packages - **`tidyverse`** (collection of packages that share same “language”) - **`ggplot2`** (popular data viz package) - **`sf`** & **`tidycensus`** packages (for easy spatial analysis) - **`citr`** & Zotero's "Better BibTex" workflow --- # Additional Self-learning Resources ## Check The LBJ R Markdown Page Later Today - A couple of R Markdown Templates Relevant To LBJ School - Policy Memorandum Template - [Lynda.com](https://lynda.com) Instructions - [Datacamp.com](https://Datacamp.com) Information --- class: center, middle, inverse # Reflecting On Why R Markdown Is The Right Tool <html><div style='float:left'></div><hr color='#bf5700' size=1px width=1100px></html> --- # By the end of today, you will: <ul class="fa-ul"> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-check-square"></i>Have R Studio installed, along with the <code>rmarkdown</code> & <code>tinytex</code> packages so you can develop R Markdown projects that knit to PDF, HTML, or Microsoft Word docs.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-check-square"></i>Know the benefits of using R Markdown compared to traditional productivity tools like Microsoft Office & Google Apps.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-check-square"></i>Have a general workflow for managing assignments, essays, or other kinds of work with R Studio projects, where R Markdown documents live.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-check-square"></i>Know the general layout of an R Markdown document, which is composed of three distinct types of text: YAML Headers, Markdown, and Code Chunks.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-check-square"></i>Successfully knit to a PDF document using R Markdown.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-check-square"></i>Have a cursory knowledge of how Latex & R Packages enhance what you can do with R Markdown.</li> -- <li style="margin-bottom: 10px;"><i class="fa-li fa fa-check-square"></i>Have provided resources for further learning & templates that are relevant to work we do here at LBJ.</li> </ul>