Lecture 28
College of Idaho
CSCI 2025 - Winter 2026
diamonds |> filter(carat > 1).
carat is a data-variable (lives in the dataframe).input$var which contains the string "carat".
input$var is an env-variable (lives in the environment).filter(diamonds, input$var > 1) tries to compare the string "carat" to 1, which fails or does weird things..data Pronoundplyr or ggplot2 exactly where to look..data[[ string ]]: Look up the column named string in the data frame..env$var: Look up the variable var in the environment (safer than implicit lookup).aes() also uses data masking..data[[ ]] to map inputs to aesthetics.select(), pivot_longer(), across() use tidy selection.select(df, carat, price).select(df, all_of(input$cols)).
all_of(): Errors if any column is missing (strict).any_of(): Ignores missing columns (lenient).filter, mutate, aes, arrange):
.data[[input$name]] to refer to a column by string.select, pivot_, across):
all_of(input$names) to refer to columns by a vector of strings.