class: center, middle, inverse, title-slide .title[ # R, RStudio - understanding Packages ] .subtitle[ ## R Workshop: August 24, 2023 ] .author[ ###
Melinda Higgins
] .date[ ### Director Biostatistics & Data Core School of Nursing - Emory University ] --- # Why Learn R? * https://www.tiobe.com/tiobe-index/r/ * https://www.tiobe.com/tiobe-index/ * https://r4stats.com/articles/popularity/ ### AND Rmarkdown... * Seamless integration of DATA + CODE + DOCUMENTATION * See examples [https://rmarkdown.rstudio.com/gallery.html](https://rmarkdown.rstudio.com/gallery.html) * Many output formats [https://rmarkdown.rstudio.com/formats.html](https://rmarkdown.rstudio.com/formats.html) * Learn more at [https://rmarkdown.rstudio.com/lesson-1.html](https://rmarkdown.rstudio.com/lesson-1.html) --- # R vs Other Stats Software .pull-left[ ## R * bare bones * takes up very little memory * powerful base packages * FREE/Open Source ] .pull-right[ ## SPSS, SAS examples * Have to buy base ($$) * AND 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%" /> ] .footnote[Add package(s) as you need them...] --- # 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 Packages Installed on Your Computer .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[ Before you can use the functions in the package installed on your computer, you must load it into your current "R session" - only loaded as needed... ```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_Aug2023.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)