If you look at a different scale on the y-axis you can see that the last non-zero value of TRUE
is just about 160000, while the last non-zero value of FALSE
is about 250000 as it should be.
So the representation is correct but it is difficult to see the tails.
To see:
data %>%
ggplot(aes(x=amountremain, color=black)) +
geom_density() +
ylim(0, 10^-5)
EDIT
@MrFlick explained why the line doesn't break.
If your goal is to interrupt the distribution of TRUE
on the last value, one possible solution is to create two distinct density dataframes:
to_dens <- function(df) {
d <- density(df)
df_d <- tibble(x = d$x, y = d$y)
return(df_d)
}
df1 <- df %>%
filter(black == TRUE) %>%
summarise(to_dens(amountremain))
df2 <- df %>%
filter(black == FALSE) %>%
summarise(to_dens(amountremain))
ggplot() +
geom_line(data = df1, aes(x = x, y = y), col = "steelblue3") +
geom_line(data = df2, aes(x = x, y = y), col = "firebrick2")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…