我是R的新手。我想根据一些特定范围获得一个两尾t检验阴影,如下所示:
set.seed(100)
time_spent1 <- data.frame(time_spent=rnorm(1000, 500, 150))
mean1 <- mean(time_spent1$time_spent)
x1 <- runif(1,0,1000)
x2 <-250
p <- ggplot(time_spent1, aes(time_spent)) +
geom_density(fill="grey") +
geom_vline(xintercept=c(x1,x2))
d <- ggplot_build(p)$data[[1]]
p <- p + geom_area(data = subset(d, x > x1), aes(x=x, y=y), fill="red")
p
此代码为我提供了右尾阴影而不是左尾。我也感谢您为左尾部加阴影的任何帮助。谢谢