class: center, middle, inverse, title-slide # Module 02: Getting Started with Packages & Data ## CDC R Workshop April 21-22, 2022 ###
Melinda Higgins
### Director Biostatistics & Data Core School of Nursing - Emory University 04/21/2022 --- # Why Learn R? * https://www.tiobe.com/tiobe-index/r/ * https://www.tiobe.com/tiobe-index/ * https://r4stats.com/articles/popularity/ --- # R vs Other Stats Software .pull-left[ ## R * bare bones * take up little memory * powerful base packages * FREE/Open Source ] .pull-right[ ## SPSS, SAS examples * Have to buy base * Almost always have to buy add-ons, gets expensive $$ * Have to know what you want ahead of time * Sometimes end up with more than you need ] --- # My SAS License Includes: <img src="sas_packages.png" width="70%" /> --- # My SPSS License Includes: <img src="spss_packages.png" width="50%" /> --- # R - Base R Packages .pull-left[ ```r sessionInfo() ``` ] .pull-right[ <img src="sessionInfo01.png" width="100%" /> ] --- # To add functionality to R - install/load Packages ### FIRST - INSTALL Package(s) .pull-left[ <img src="install_packages01.png" width="60%" /> ] .pull-right[ <img src="install_packages02.png" width="90%" /> ] --- # List of Packages on Your Machine .pull-left[ <img src="packages_list_user.png" width="100%" /> ] .pull-right[ <img src="packages_list_system.png" width="100%" /> ] --- ### SECOND - LOAD Package(s) into Current R Session .pull-left[ ```r # load tidyverse library(tidyverse) # run sessionInfo() again # now how many packages are "attached" # under "other attached packages" sessionInfo() ``` ] .pull-right[ <img src="sessionInfo02.png" width="100%" /> ] --- # Where to get R Packages - CRAN <iframe src="https://cran.r-project.org/" width="100%" height="400px" data-external="1"></iframe> .footnote[[https://cran.r-project.org/](https://cran.r-project.org/)] --- # Where to get R Packages - Bioconductor <iframe src="https://www.bioconductor.org/" width="100%" height="400px" data-external="1"></iframe> .footnote[[https://www.bioconductor.org/](https://www.bioconductor.org/)] --- # Where to get R Packages - Github, Local, Others... [https://github.com/search?l=R&q=packages&type=Repositories](https://github.com/search?l=R&q=packages&type=Repositories) <img src="GithubRPackages.png" width="100%" /> --- # Do Your Research * Always research your packages - like any other "tool" * has it be validated? * has it been published? * has is it been used/accepted in your research field or application? -- * Check download stats: [https://hadley.shinyapps.io/cran-downloads/](https://hadley.shinyapps.io/cran-downloads/) -- * Check CRAN: e.g. `tidyverse` [https://cran.r-project.org/web/packages/tidyverse/index.html](https://cran.r-project.org/web/packages/tidyverse/index.html): * check date last updated * how many versions * how long has it existed -- * Check Github repo if exists, check issues: * `tidyverse` [https://github.com/tidyverse/tidyverse](https://github.com/tidyverse/tidyverse) --- class: inverse, middle, left # Your Turn [ZOOM BREAKOUT, 10 MIN] ### 1. Open "module02_Rscript.R" ### 2. Read instructions for EXERCISE 01 * Go to https://hadley.shinyapps.io/cran-downloads/ * How many downloads have there been (on average) recently: * for the `ggplot2` and `palmerpenguins` packages? * remove `ggplot2` and make plot again * compare downloads for `arsenal` and `gtsummary` packages * Go to https://cran.r-project.org/ - click on packages: * how many Packages are on CRAN today? * list by name and find `ggplot2` package * when was it last updated? * go to github repo for ggplot2 - any open issues? --- # Interactive RStudio ### 1. Open RStudio ### 2. Open "module02_Rscript.R" ### 3. Go to "DATASETS"