Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with new ggplot2 version #2

Open
thomasp85 opened this issue Jun 9, 2020 · 0 comments
Open

Issue with new ggplot2 version #2

thomasp85 opened this issue Jun 9, 2020 · 0 comments

Comments

@thomasp85
Copy link

Hi

We see an issue with the latest ggplot2 version. The issue is related to this function

get_posterior_data <- function(data, lower_cut=NULL, upper_cut=NULL, interp_thresh=NULL,
mirror=FALSE, colour="#000000", fill=NA, warn=TRUE) {
dt <- compute_post_seg_data(data, lower_cut, upper_cut, interp_thresh, warn)
# find the bottom and top parts of the distribution to make a complete line
assert_names(c("ymin", "ymax", "grp_max", "grp_min"), data)
if (mirror) {
dt[, `:=`(ylower=grp_max / 2 + grp_min - y / 2, yupper=grp_max / 2 + y / 2)]
adj <- 0
adj <- dt[
, .(adj=mean(c(ymax, ymin)) - mean(c(grp_min, grp_max))),
.(grp_min, grp_max, ymin, ymax)
] %>%
.[, adj]
dt[, `:=`(ylower=ylower + adj, yupper=yupper + adj)]
} else {
dt[, `:=`(ylower=grp_min, yupper=y)]
}
rbind(
copy(dt) %>%
.[, y := ylower] %>%
.[order(x)],
copy(dt) %>%
.[, y := yupper] %>%
.[order(-x)]
) %>%
rm_temp_cols(c("colour", "fill")) %>%
.[, `:=`(colour=colour, fill=fill)] %>%
rbind(.[1, ])
}

where data.table fails to properly rbind things together. The change in ggplot2 that provoked this is that position aesthetics that originated as discrete values now has an additional class added to them so that they are easily distinguishable from continuous data. It appears data.table does not coerce this class down to its numeric base, so you might have to do that manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant