library(tidyverse)
#> ── Attaching core tidyverse packages ───────────────────── tidyverse 2.0.0 ──
#> ✔ dplyr 1.1.2 ✔ readr 2.1.4
#> ✔ forcats 1.0.0 ✔ stringr 1.5.0
#> ✔ ggplot2 3.4.2 ✔ tibble 3.2.1
#> ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
#> ✔ purrr 1.0.1
#> ── Conflicts ─────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag() masks stats::lag()
#> ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
3 Workflow: basics
Prerequisites
3.5 Exercises
The variable is called
my_variable
while the next line calls itmy_varıable
, with an anı
(i
without a dot) in the variable name. Therefore the error is due to the mismatch in variable names.-
The corrected code is provided below.
library(tidyverse) ggplot(mpg, aes(x = displ, y = hwy)) + geom_point() + geom_smooth(method = "lm") #> `geom_smooth()` using formula = 'y ~ x'
Option + Shift + K / Alt + Shift + K pulls up keyboard shortcuts. Alternatively, you can get to the same place with Help > Keyboard Shortcuts Help.
-
The
my_bar_plot
object is saved because that’s what was specified in theplot
argument of theggsave()
call.