class: center, middle, inverse, title-slide #
Getting Started in R
an introduction to data analysis and visualisation
## Welcome! ### Réka Solymosi & Sam Langton & Emily Buehler ### 1 July 2019 --- class: inverse, center, middle # Welcome! --- ## About us <img src="https://avatars1.githubusercontent.com/u/7291547?v=3&s=400" width="100px" /> @r_solymosi <img src="https://avatars0.githubusercontent.com/u/36928709?s=400&v=4" width="100px" /> @sh_langton <img src="https://pbs.twimg.com/profile_images/826431771868807168/42VQ-_sY_400x400.jpg" width="100px" /> @emily_buehler --- ## About you --- ## About the course **Schedule** | | Slot | Module | |:--------|:-------|:------------------------------------------------------| | **1** | Mon pm | Intro | | **2.1** | Tue am | Basics | | **2.2** | Tue pm | Import data | | **3.1** | Wed am | Tidy data | | **3.2** | Wed pm | Transform data | | **4.1** | Thu am | Visualise data | | **4.2** | Thu pm | Model data | | **5** | Fri am | Reporting data | <br> --- ## About the course By the end of the week you will be able to: - be able to read and write basic R code - read your data into R Studio - tidy (prep) your data for analysis - filter and subset data - summarise and create new variables - visualise your data - model your data - presenting results in a report --- ## Why R? - growing popularity - reproducable - learn to code - diverse - open source - community driven --- ## Growing popularity <img src="https://i0.wp.com/r4stats.com/wp-content/uploads/2017/06/Fig_2d_ScholarlyImpact2016.png" height="450px" /> source: http://r4stats.com/articles/popularity/ --- ## Growing popularity <img src="https://i0.wp.com/r4stats.com/wp-content/uploads/2017/06/Fig_2e_ScholarlyImpactSubset2016.png?w=650" height="450px" /> source: http://r4stats.com/articles/popularity/ --- ## Growing popularity <img src="https://i0.wp.com/r4stats.com/wp-content/uploads/2017/02/Fig-1a-IndeedJobs-2017.png?w=650" height="450px" /> source: http://r4stats.com/articles/popularity/ --- ## Reproducible <img src="img/goldacre_tweet.png" width="600px" /> --- ## Reproducible <img src="img/goldacre_tweet_2.png" width="600px" /> --- ## Reproducible: the point - People are very opinionated about it - Replication and transparency is a key debate in research - The need for replication is blind to research discipline - One day we might not have a choice in the matter - Either way, it will make your life a lot easier! --- ## Diverse: Inferential stats ```r library(stats) ``` ```r mean() sd() chisq.test() t.test() aov() glm() ``` --- ## Diverse: Plots ```r plot(cars$speed, cars$dist) ``` <img src="slides_files/figure-html/unnamed-chunk-11-1.png" width="450px" /> --- ## Diverse: Plots ```r library(ggplot2) ``` <img src="slides_files/figure-html/unnamed-chunk-13-1.png" width="500px" /> --- ## Diverse: Plots ```r library(waffle) ``` <img src="slides_files/figure-html/unnamed-chunk-15-1.png" height="450px" /> --- ## Diverse: Maps ```r library(ggplot2) ; library(sf) ``` <img src="img/original_plot.png" width="450px" /> --- ## Diverse: Stylised Maps ```r library(ggplot2) ; library(sf) # + open code ``` <img src="img/hexo_plot.png" width="450px" /> --- ## Diverse: Sequence analysis ```r library(TraMineR) ``` <img src="img/traminer.png" width="1821" /> --- ## Diverse: Spatial autocorrelation ```r library(spdep) ``` <img src="img/spdep.png" width="700px" /> --- ## Diverse: Aoristic analysis ```r library(aoristic) ``` <img src="img/aoristic.png" width="700px" /> --- ## Diverse: Social network analyis ```r library(igraph) ``` <img src="http://www.rdatamining.com/_/rsrc/1336980493578/examples/social-network-analysis/sna-terms-1.png" height="450px" /> --- ## Diverse: Text mining ```r library(tidytext) ; library(geniusR) ``` <img src="img/smiths-studio-albums.png" width="480px" /> --- ## Diverse: Text analysis ```r library(tidytext) ; library(geniusR) ``` ![](https://i2.wp.com/www.johnmackintosh.com/img/2018-01-28-album-word-correlations-original.png?w=456&ssl=1)<!-- --> [Source: John MacKintosh on R bloggers](https://www.r-bloggers.com/hardwired-for-tidy-text/) --- ## Diverse: Text analysis ```r library(tidytext) ``` <img src="img/lotr_text.png" width="550px" /> [Source: Jakub Glinka on R bloggers](https://www.r-bloggers.com/sentiment-analysis-of-the-lord-of-the-rings-with-tidytext/) --- ## Diverse: interactive maps ```r library(tmap) ``` ![](img/ME_gif.gif)<!-- --> --- ## Diverse: Shiny apps to visualise voting <img src="img/brexit.gif" width="700px" /> --- ## Open tools <img src="img/open_tools.png" width="700px" /> --- ## Open source <img src="https://media.giphy.com/media/A06UFEx8jxEwU/giphy.gif" width="600px" /> --- ## Open source <img src="img/ggplot_coord_flip.png" width="600px" /> --- ## Community driven <img src="img/r_cult.png" width="600px" /> --- ## Community driven <img src="img/r_help.png" width="600px" /> --- ## Community driven <img src="img/manchester_r.png" width="1325" /> --- ## Community driven <img src="https://avatars1.githubusercontent.com/u/11410476?v=3&s=200" width="150px" /><img src="img/r_ladies.png" width="150px" /><img src="https://d21ii91i3y6o6h.cloudfront.net/gallery_images/from_proof/12936/large/1464301097/number-rcatladies.png" width="150px" /><img src="https://pbs.twimg.com/media/CyW_of8XAAAbKul.jpg" width="150px" /> --- ## Community driven <img src="img/rpubs.png" width="600px" /> --- ## Community driven <img src="img/accidental_aRt.png" width="600px" /> --- ## Community driven <img src="img/google_how_to.gif" width="600px" /> --- ## Community driven <img src="img/youtube.png" width="600px" /> --- ## Community driven Top resources: - Stack Overflow - RPubs - R4DS - Twitter --- ## Community driven <img src="img/twitter_profiles.png" width="700px" /> --- ## Join the community <img src="https://media.giphy.com/media/l3UcwPQnD2yQ62vWE/giphy.gif" width="600px" /> --- ## After coffee - get to know R Studio - learn about packages - open, edit and run an R script - save the output