Slide 1

Slide 1 text

RStudio and R Resources Happy Scientist Seminar Emil Hvitfeldt 2019-1-22

Slide 2

Slide 2 text

Motivation We will talk about what you are able to do in RStudio with R and where to find information and rescources to do it great.

Slide 3

Slide 3 text

- Data analysis scripts - Interactive web applications - Documents - Reports - Graphs - more - Syntax highlighting - code completion - smart indentation - Integrated R help - data viewer - Version control with Git

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Packages Idea -> Code -> Package -> Share -> Happiness If you want to do something, chance has it someone have worked on it before

Slide 10

Slide 10 text

CRAN (The Comprehensive R Archive Network) https://cran.r-project.org/

Slide 11

Slide 11 text

https://cran.r- project.org/web/packages/available_packages_by_name.html

Slide 12

Slide 12 text

https://cran.r-project.org/web/views/

Slide 13

Slide 13 text

https://www.bioconductor.org/

Slide 14

Slide 14 text

https://www.bioconductor.org/packages/release/BiocViews.html#___Software

Slide 15

Slide 15 text

R Markdown - Compile a single R Markdown document to a report in different formats, such as PDF, HTML, or Word. - Make slides for presentations (HTML5, LaTeX Beamer, or PowerPoint). - Build interactive applications based on Shiny. - Write journal articles. - Much more.

Slide 16

Slide 16 text

Creating a R Markdown file

Slide 17

Slide 17 text

Creating a R Markdown file

Slide 18

Slide 18 text

Creating a R Markdown file

Slide 19

Slide 19 text

Creating a R Markdown file

Slide 20

Slide 20 text

Creating a R Markdown file

Slide 21

Slide 21 text

--- title: "Amazing Document" author: "Emil Hvitfeldt" date: "1/20/2019" output: html_document --- YAML (optional)

Slide 22

Slide 22 text

--- title: "Amazing Document" author: "Emil Hvitfeldt" date: "1/20/2019" output: html_document --- YAML: YAML Ain't Markup Language

Slide 23

Slide 23 text

--- title: "Amazing Document" author: "Emil Hvitfeldt" date: "1/20/2019" output: html_document --- Chunks of code surrounded by ``` YAML (optional) The R in R Markdown

Slide 24

Slide 24 text

--- title: "Amazing Document" author: "Emil Hvitfeldt" date: "1/20/2019" output: html_document --- Chunks of code surrounded by ``` Text with simple text formating. YAML (optional) The R in R Markdown The Markdown in R Markdown

Slide 25

Slide 25 text

What we write --- author: "Emil Hvitfeldt" date: "1/20/2019" output: html_document --- We built a **linear** regression model. ```{r} fit <- lm(mpg ~ disp, data = mtcars) b <- coef(fit) plot(mpg ~ disp, mtcars) ``` The slope of the regression is `r round(b[1], digits = 1)` in the output.

Slide 26

Slide 26 text

What we write --- author: "Emil Hvitfeldt" date: "1/20/2019" output: html_document --- We built a **linear** regression model. ```{r} fit <- lm(mpg ~ disp, data = mtcars) b <- coef(fit) plot(mpg ~ disp, mtcars) ``` The slope of the regression is `r round(b[1], digits = 1)` in the output. What we get

Slide 27

Slide 27 text

What we write --- author: "Emil Hvitfeldt" date: "1/20/2019" output: pdf_document --- We built a **linear** regression model. ```{r} fit <- lm(mpg ~ disp, data = mtcars) b <- coef(fit) plot(mpg ~ disp, mtcars) ``` The slope of the regression is `r round(b[1], digits = 1)` in the output.

Slide 28

Slide 28 text

What we write --- author: "Emil Hvitfeldt" date: "1/20/2019" output: pdf_document --- We built a **linear** regression model. ```{r} fit <- lm(mpg ~ disp, data = mtcars) b <- coef(fit) plot(mpg ~ disp, mtcars) ``` The slope of the regression is `r round(b[1], digits = 1)` in the output. What we get

Slide 29

Slide 29 text

- github_document - html_document - latex_document - md_document - odt_document - pdf_document - rtf_document - word_document - ioslides_presentation - powerpoint_presentation - slidy_presentation - beamer_presentation Build-in Formats

Slide 30

Slide 30 text

Notable Extensions

Slide 31

Slide 31 text

Notable Extensions - xaringan

Slide 32

Slide 32 text

Notable Extensions - xaringan - flexdashboard

Slide 33

Slide 33 text

Notable Extensions - xaringan - flexdashboard - learnr

Slide 34

Slide 34 text

Notable Extensions - xaringan - flexdashboard - learnr - rticles

Slide 35

Slide 35 text

https://github.com/yihui/xaringan

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Sales Forecast Sales by State Series ETS(M,A,M) level 90

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Welcome Visualisation is an important tool for generating insights, but your data wonʼt always arrive ready to visualize. Often youʼll need to filter unwanted observations from your data or create new variables and summaries to visualize. In this tutorial, you will learn how to filter your data, including: How to use filter() to extract observations that pass a logical test How to write logical comparisons in R How to combine logical comparisons with Boolean operators How to handle missing values within comparisons The readings in this tutorial follow R for Data Science (http://r4ds.had.co.nz/), section 5.2. Continue

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Shiny Combines the computational power of R with the interactivity of the modern web. Powerful web framework.

Slide 43

Slide 43 text

https://gallery.shinyapps.io/050-kmeans-example/ Iris k-means clustering X Variable Y Variable Cluster count 3 Kmeans example by Joe Cheng (http://www.rstudio.com/)  show with app function(input, output, session) { # Combine the selected variables into a new data frame selectedData <- reactive({ server.R ui.R Sepal.Length Sepal.Width

Slide 44

Slide 44 text

https://gallery.shinyapps.io/082-word-cloud/ Word Cloud Choose a book: Change Minimum Frequency: Maximum Number of Words: 1 50 15 1 11 21 31 41 1 300 100 1 61 121 241 Word cloud by Fereshteh Karimeddini (http://www.rstudio.com/) A simple word cloud generator, based on  show with app # Text of the books downloaded from: # A Mid Summer Night's Dream: # http://www.gutenberg.org/cache/epub/2242/pg2242.txt global.R server.R ui.R A Mid Summer Night's Dream

Slide 45

Slide 45 text

https://gallery.shinyapps.io/086-bus-dashboard/ Show Note: a route number can have several different trips, each with a different path. Only the most commonly- used path will be displayed on the map. Zoom to fit buses Northbound Southbound Eastbound Westbound Refresh interval Refresh now Source data updates every 30 seconds. 1 minute

Slide 46

Slide 46 text

https://apps.garrickadenbuie.com/rstudioconf-2019/ 40 Tweets Today  39 Tweeters Today  2.16 Tweets/hr Today  56,006 rstudio::conf Likes  4,120 rstudio::conf Tweets  10,597 #rstats Tweets  Tweet Volume Tweets by Hour of Day Most Liked in 12 Hours

Slide 47

Slide 47 text

http://www.dataseries.org/ TIDIED UP Switzerland's data series in one place Choose variable, e.g., GDP

Slide 48

Slide 48 text

Where do I go for more information? - Cheatsheets - Books - rweekly.org - Forums - USCbiostats/software-dev

Slide 49

Slide 49 text

Have a question? Google it https://www.google.com/

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

https://rseek.org/

Slide 52

Slide 52 text

https://rseek.org/

Slide 53

Slide 53 text

Cheatsheets https://www.rstudio.com/resources/cheatsheets/

Slide 54

Slide 54 text

Books https://bookdown.org/

Slide 55

Slide 55 text

Books

Slide 56

Slide 56 text

https://www.rweekly.org/

Slide 57

Slide 57 text

https://community.rstudio.com/ https://stackoverflow.com/

Slide 58

Slide 58 text

https://github.com/USCbiostats/software-dev