-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Summary
- plot_smooth_compare() renames the helper columns age_mid and plot_y to user-facing labels (Age, Exposures, etc.). Because the original tibbles already contain Age/variable, the helper now returns duplicate
column names. - Every consumer of smooth_flexible() inherits those duplicates.
Proposed change
./R/graduation.R
- names(data_in)[names(data_in) == "age_mid"] <- age_text
- names(data_out)[names(data_out) == "age_mid"] <- age_text
- names(data_in)[names(data_in) == "plot_y"] <- variable_display
- names(data_out)[names(data_out) == "plot_y"] <- variable_display
...
- sym_variable_display <- sym(variable_display)
- sym_age_text <- sym(age_text)
+ sym_variable_display <- sym("plot_y")
+ sym_age_text <- sym("age_mid")
...
- labs(title = title_text,
- x = age_text,
- y = variable_display)
...
+ labs(title = title_text,
+ x = age_text,
+ y = variable_display)
- We keep the translated axis labels via labs() but stop renaming the data frame columns.
- Result: data_adjusted / data_original still carry the helper variables, but with unique names (age_mid, plot_y). Plotly and downstream consumers now work without additional sanitising.
You can test with:
df <- data.frame(Age = c(0, 1, 5), Exposures = c(10, 20, 30))
res <- ODAPbackend:::plot_smooth_compare(df, df, "Exposures")
names(res$data_adjusted)
# before: "Age" "Exposures" ... "Age" "Exposures"
# after: "Age" "Exposures" "single" "AgeInt" "age_mid" "age_label" "plot_y"
Everything else (figure output, labels, translations) remains unchanged.
Metadata
Metadata
Assignees
Labels
No labels