-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Below is a simple example in which I prepare two scatter plots using the mtcars data set. var
contains the name of the variable in mtcars which should be plotted on the y axis. Notice when I change the value of var
the plot is automatically updated without any formal assignment. Does this happen on your end as well? Is this normal behaviour? Many thanks.
library(ggplot2)
data(mtcars)
var <- "cyl"
g <- ggplot(mtcars, aes(get(var), mpg)) + geom_point()
g
# change the value of var
var <- "wt"
# look at the original (!) plot
g
Created on 2024-07-11 with reprex v2.1.1
This was prepared in a clean environment, R v4.4.1, ggplot2 v3.5.1
Metadata
Metadata
Assignees
Labels
No labels