Download presentation
Presentation is loading. Please wait.
Published byGwendolyn Hodge Modified over 6 years ago
1
Installing Packages Introduction to R, Part II
Anna Blackstock Statistician, Biostatistics and Information Management Office (BIMO) NCEZID/DFWED
2
Overview In Part I, you learned a lot about the basics, including:
Atomic and composite data types Atomic: character, numeric, logical Composite: vector, matrix, data frame, … Functions is.* and as.* functions, summary(), names(), subset(), … Operators (assignment, arithmetic, logical): =, <-, +, -, *, /, <, >, <=, >=, !=, ==
3
Overview Part II will be about extending R so that you can use it in your work We’ll cover: Installing R packages Getting data in and out of R Exploring data Writing functions
4
R Packages Packages are constantly being developed
There are almost 13,000 add-on packages available* Packages are constantly being developed After development, packages are available immediately Go to for links to lists of packages. *This number has more than doubled from 5000 in 2013.
5
What is an R package? R packages are collections of functions, datasets, and code that are available for download Functions in a package often have a common theme Importing data (haven, readxl, rgdal, …) Statistical analysis (survey, survival, ...) Producing graphs (lattice, ggplot2, ...) For more information, see
6
Which packages do you want?
Usually, the need comes before the downloading of a package! Think about: the data you have at hand the analysis you would like to do or the plot you would like to create Note: the quality of packages and package documentation can vary.
7
Which packages do you want?
For (trusted) packages by area, see project.org/web/views/
8
How do you get packages into R?
To use functions in a package, you need to do two things: Install the package (once) Load the package (before every use) (For installation in RStudio, you can also go to Tools -> Install Packages…)
9
Installing R Packages . . . at the CDC
CDC users generally cannot make changes to folders where programs are saved (C:/Program Files) The default location for installing R packages is in this folder, so you’ll need to: create a new folder elsewhere tell R to install packages in and load packages from this new folder (or save R somewhere else, but we won’t cover this)
10
Installing R Packages . . . at the CDC
The RUG website has detailed instructions on installing packages at the CDC. Method 2 has two options: “every time way”: specify package location each time packages are saved or used “forever way”: specify package location in file where R sees start-up commands See
11
The CRAN Mirror When you install packages, you are downloading from a CRAN (Comprehensive R Archive Network) mirror, a replica of all R code and documentation SciComp and RUG have set up a local CRAN mirror:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.