install.packages("palmerpenguins")
Data Processing and Visualization in R
2025-01-23
R is a statistical programming language.
R is a statistical programming language.
R is a statistical programming language.
R is a statistical programming language.
R is a statistical programming language.
It allows you to flexibly
wrangle data
visualize data
analyze data
create reproducible documents
All code
is in monospace font purple text
R functions end with parentheses: function()
Directory names end with slash: home/
Package names are surrounded by curly braces: {tidyverse}
Keyboard buttons separate keys with a plus: Ctrl+S
These are parentheses ()
, brackets []
, and braces {}
Links are in light blue text
Download at https://r-project.org.
For Windows, also install Rtools
RStudio is an Integrated Development Environment (IDE). Download from Posit
Using the R console
Packages are collections of function and data sets
Base R is a core set of packages for all R installations.
Note
User-contributed packages can be found on the Comprehensive R Archive Network or CRAN.
In the console type
install.packages("<package_name>")
where <package_name>
is the name of the package.
Try installing the {palmerpenguins}
package.
install.packages("palmerpenguins")
You can install multiple packages simultaneously by wrapping them with c()
. For example,
install.packages(c("remotes", "here"))
Load the {here}
package:
Note
Every time you close your R session, you’ll have to reload the packages you were using.
Let’s view the penguins
data set from the {palmerpenguins}
package.
Try this:
penguins
You should receive Error: object 'penguins' not found
. Why did you receive this error?
But you can either load the {palmerpenguins}
package, or use this trick to call a specific function from a specific package.
palmerpenguins::penguins
# A tibble: 344 × 8
species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
<fct> <fct> <dbl> <dbl> <int> <int>
1 Adelie Torgersen 39.1 18.7 181 3750
2 Adelie Torgersen 39.5 17.4 186 3800
3 Adelie Torgersen 40.3 18 195 3250
4 Adelie Torgersen NA NA NA NA
5 Adelie Torgersen 36.7 19.3 193 3450
6 Adelie Torgersen 39.3 20.6 190 3650
7 Adelie Torgersen 38.9 17.8 181 3625
8 Adelie Torgersen 39.2 19.6 195 4675
9 Adelie Torgersen 34.1 18.1 193 3475
10 Adelie Torgersen 42 20.2 190 4250
# ℹ 334 more rows
# ℹ 2 more variables: sex <fct>, year <int>
Install R from https://r-project.org
Install RStudio from https://posit.co
Install {tidyverse}
package
Complete course introduction form
Read the syllabus
Read readings in syllabus schedule