safety outlier_explorer is using geom_path and not geom_line (see the code below). This means that according to the ggplot doc:
geom_path() connects the observations in the order in which they appear in the data. geom_line() connects them in order of the variable on the x axis. geom_step() creates a stairstep plot, highlighting exactly when changes occur. The group aesthetic determines which cases are connected together.
This seems unintuitive, in my opinion, as one would expect that the lines would be ordered according to the x axis as, in this particular case, it is related to the relative study date and it does not make much sense to order things according to the appearance in the data.
Thanks a lot for the package, I am really enjoying it!
safety_outlier_explorer <- function(data, settings) {
params <- aes_(
x = as.name(settings$studyday_col),
y = as.name(settings$value_col),
group = as.name(settings$id_col)
)
if (hasName(settings, "measure_values")) {
sub <- data %>% filter(!!sym(settings$measure_col) %in% settings$measure_values)
} else {
sub <- data
}
p <- ggplot(data = sub, params) +
geom_path(color = "black", alpha = 0.15) +
labs(x = "Study Day", y = "Lab Value", title = "Lab Overview", subtitle = "") +
facet_grid(
rows = as.name(settings$measure_col),
scales = "free_y"
) +
theme_bw()
return(p)
}
Thanks for filing the issue and for the nice comments on the package, @zsigmas. Agree with your comment. Feel free to put in a PR with a fix if desired - otherwise someone on the team will tackle it ASAP.
Hi all,
safety outlier_explorer
is usinggeom_path
and notgeom_line
(see the code below). This means that according to the ggplot doc:This seems unintuitive, in my opinion, as one would expect that the lines would be ordered according to the x axis as, in this particular case, it is related to the relative study date and it does not make much sense to order things according to the appearance in the data.
Thanks a lot for the package, I am really enjoying it!