I want the geom point to alternate between the halfeye densities. The objective is to have true values close to the simulated density curve, so b3_hat then b3 right below. Is it possible? Here is the code:
library(forcats)
library(ggdist)
# use the bias data to plot the halfeye
plot_data <-bias %>%
select(mrdoc2_b1_hat, b1,
mrdoc2_b3_hat, b3) %>%
select(!contains("_se")) %>%
# pivot all columns
pivot_longer(cols = everything(),
names_to = "key", values_to = "value")
# Create the halfeye plot
plot_data %>%
ggplot(aes(x = value, y = fct_reorder(key, value))) +
stat_halfeye(data = plot_data %>% filter(str_detect(key, "_hat$"))) +
# we'll add the data back in too (scale = .5 above adjusts the halfeye height so
# that the data fit in as well)
geom_point(aes(x = value), data = plot_data %>% filter(!str_detect(key, "_hat$")), pch = "|", size = 2, position = position_nudge(y = -.15))
