Displaying 3 results from an estimated 3 matches for "after_stat".
Did you mean:
afr_stat
2023 Jan 12
1
Reg: ggplot error
...ody would like to go through your whole code.
1. data seems to be read correctly
ICUData <- read.csv(file = "ICUData.csv", stringsAsFactors = TRUE)
ICUData.neuro <- ICUData[ICUData$surgery == "neuro",]
2. ggplot(ICUData, aes(x=ICUData.neuro$LOS)) +
geom_histogram(aes(y=after_stat(density)), binwidth = 5,
fill = "darkgrey")
gives me error
Error in `check_aesthetics()`:
! Aesthetics must be either length 1 or the same as the data (500): x
Run `]8;;rstudio:run:rlang::last_error()rlang::last_error()]8;;` to see where the error occurred.
which, I b...
2023 Aug 12
1
geom_smooth
...ribbon but I cannot figure this out. Some
> advice would be welcome.
This works for me:
ggplot(scatter_data,aes(x=x_var,y=y_var,))+
geom_point()+
geom_smooth(se=TRUE,fill="blue",color="black",linetype="dashed") +
geom_ribbon(stat="smooth", aes(ymin=after_stat(ymin), ymax=after_stat(ymax)), fill=NA, color="black")+
theme_cowplot()
Cheers,
Berwin
2023 Aug 12
2
geom_smooth
Colleagues,
Here is my reproducible code for a graph using geom_smooth
set.seed(55)
scatter_data <- tibble(x_var = runif(100, min = 0, max = 25)
?????????????????????? ,y_var = log2(x_var) + rnorm(100))
library(ggplot2)
library(cowplot)
ggplot(scatter_data,aes(x=x_var,y=y_var))+
? geom_point()+
? geom_smooth(se=TRUE,fill="blue",color="black",linetype="dashed")+