R
Completed
-
Section 1: Getting Started
-
Section 2: Core Syntax
-
Section 3: Data Structures
-
Section 4: Data Manipulation
-
Section 5: Visualization and Statistics
-
Section 6: Advanced R
-
Section 7: Practical Projects
-
Section 8: Interview Practice
-
Section 9: More Practice Exercises
-
Section 10: Shiny Apps in Depth
-
Section 11: More Data Wrangling
-
Section 12: Tidyverse Deep Dive
-
Section 13: Statistical Modeling Deep Dive
-
Section 14: Machine Learning in R
-
Section 15: R Visualization Deep Dive
-
Section 16: R Package Development Deep Dive
-
Section 17: R for Reproducible Research
-
Section 18: R and Databases
-
Section 19: R Performance Optimization
-
Section 20: Bioinformatics and Specialized R
-
Section 21: More Shiny Practice
-
Section 22: More Practice Exercises
-
Section 23: R Data Structures Deep Dive
-
Section 24: More Interview and Review
-
Section 25: R for Business Analytics
-
Section 26: R Text Mining and NLP
-
Section 27: R Spatial Data Analysis
-
Section 28: R Deep Learning
-
Section 29: Advanced Statistical Techniques
-
Section 30: R Object Systems Deep Dive
-
Section 31: R Environments and Metaprogramming
-
Section 32: R for Finance
-
Section 33: R for Clinical and Health Data
-
Section 34: More Shiny Advanced Practice
-
Section 35: R Data Cleaning Deep Dive
-
Section 36: R Reporting Automation
-
Section 37: More Practical Projects Round 2
-
Section 38: R Ecosystem and Career
-
Section 39: More Visualization Practice
-
Section 40: R for Experimentation
-
Section 41: R for Genomics and Bioinformatics Deep Dive
-
Section 42: R for Marketing Analytics
-
Section 43: R Data Import/Export Deep Dive
-
Section 44: R String Processing Deep Dive
-
Section 45: R for Actuarial and Insurance Analytics
-
Section 46: R Testing and Quality Assurance Deep Dive
-
Section 47: R Version Control and Collaboration
-
Section 48: R Advanced Functional Programming
-
Section 49: R for Supply Chain and Operations
-
Section 50: More Practice Exercises Round 3
-
Section 51: R Dashboards and BI Integration
-
Section 52: R Data Governance and Ethics
-
Section 53: More Modeling Practice
-
Section 54: R Final Capstone Projects
-
Section 55: R for Sports Analytics
-
Section 56: More Interview Practice Round 2
-
Section 57: R Networking and APIs
-
Section 58: R for Environmental Science
-
Section 59: R Notebook and Documentation Practices
-
Section 60: More Data Wrangling Mastery
-
Section 61: R for A/B Testing at Scale
-
Section 62: R Package Ecosystem Deep Dive
3: R Package Ecosystem Overview
I was messing around with some data this morning and I realized I wanted to create a scatter plot of penguin flipper lengths versus bill depths. I've got the data in a dataframe, but I'm tired of fighting with the base R plot() arguments to make it look professional. I want to use ggplot2 because it's the industry standard for a reason.
The "Could not find function" wall
I'll start by trying to call the plotting function. Here is where I usually trip up if I've just opened a fresh R session:
ggplot(penguins, aes(x = flipper_length_mm, y = bill_depth_mm)) +
geom_point()
R immediately throws an error: Error in ggplot(...) : could not find function "ggplot". Right. I forgot that just because a package exists in the R universe doesn't mean it's currently loaded into my brain—or my workspace. I try to load it:
library(ggplot2)
And there it is: Error in library(ggplot2) : there is no package called ‘ggplot2’. This is the crucial distinction in R that confuses a lot of people. install.packages() puts the code on your hard drive (like downloading an app), but library() puts it into your current session's memory (like opening the app). Since this is a fresh environment, I haven't even downloaded it yet.
Tapping into CRAN
I need to get ggplot2. I'll run the installation command:
install.packages("ggplot2")
While that's running, notice what's happening in the console. R isn't just grabbing one file; it's downloading a handful of other packages too. You'll see things like rlang, lifecycle, and gtable flying by. This is the "dependency" system. ggplot2 doesn't reinvent the wheel; it relies on these smaller, specialized packages to handle low-level logic. They all come from CRAN (The Comprehensive R Archive Network), which is essentially the "App Store" for R. It's strictly curated, meaning if a package is on CRAN, it's passed a set of quality and compatibility tests.
The Tidyverse shortcut
Now, I actually need the penguin data itself. I remember there's a package called palmerpenguins. I could install that individually, but as I'm working, I realize I'll probably need dplyr for filtering and tidyr for cleaning. I could run install.packages() three more times, or I can use a metapackage.
install.packages("tidyverse")
library(tidyverse)
The tidyverse isn't really a single package; it's a collection. By loading it, I've just brought in ggplot2, dplyr, readr, and several others in one go. It's a huge time-saver, though in a production script, I'd eventually narrow this down to only the specific libraries I need to keep the memory footprint small. I'm in exploration mode, so "load everything" works fine for now.
Going off-road to GitHub
Here is where it gets interesting. I heard about a niche package that adds some fancy custom themes to ggplot, but it's not on CRAN yet because the author is still tweaking it. If I try install.packages("fancy-themes"), it'll fail because CRAN doesn't know it exists.
To get this, I have to go straight to the source: GitHub. I'll use the remotes package to handle this:
install.packages("remotes")
remotes::install_github("username/fancy-themes")
This is the "wild west" of the ecosystem. Unlike CRAN, there's no gatekeeper here. You're installing code directly from a developer's repository. It's incredibly powerful for getting the latest features, but it's also how you accidentally break your environment if the developer pushed a buggy commit ten minutes ago. I generally reserve GitHub installs for specific tools or when I'm contributing to the package development myself.
📋 Practical Task
Building a Penguin Morphometrics Visualization
Your task is to move from a blank R session to a completed visualization using the package ecosystem. Follow these requirements:
- Install and load the
palmerpenguinspackage to access the dataset. - Install and load the
ggplot2package. - Create a scatter plot using the
penguinsdataset where:- The x-axis is
bill_length_mm. - The y-axis is
bill_depth_mm. - The points are colored by the
speciescolumn.
- The x-axis is
- Add a title to your plot: "Penguin Bill Dimensions by Species".
Goal: Demonstrate that you can successfully navigate the install $\rightarrow$ load $\rightarrow$ execute workflow across different packages.
There are no comments for now.