R — Packages
Installing packages
# Install from CRAN
install.packages("ggplot2")
install.packages("dplyr")
# Install from GitHub
# install.packages("devtools")
devtools::install_github("tidyverse/dplyr")
Loading packages
# Load package
library(ggplot2)
# Use with :: (no need to load)
dplyr::filter(data, x > 5)
# Search
find.package("ggplot2")
Popular packages
| Package | Purpose |
|---|---|
| dplyr | Data manipulation |
| ggplot2 | Data visualization |
| tidyr | Data tidying |
| readr | Read data |
| stringr | String manipulation |
| lubridate | Date/time |
| purrr | Functional programming |
| forcats | Factor manipulation |
| readxl | Read Excel files |
| jsonlite | Read/write JSON |
Package management
# List installed packages
installed.packages()
# Update packages
update.packages()
# Remove package
remove.packages("package_name")
# Check package version
packageVersion("ggplot2")
Mini Practice
Write R code that:
- Installs and loads a package
- Uses a package function
- Lists installed packages
- Updates packages
Up Next
In the next lesson, you'll learn about Data Import — reading data from files.
Related Topics
Frequently Asked Questions about Packages
What is Packages in R?
Packages is a fundamental concept in R. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Packages?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Packages.
Why is Packages important in R?
Packages is essential for R development. Understanding this concept will help you write better code and solve real-world problems more effectively.