I rerun the code from this link with the version of ggplot2==3.3.5
:
df <- structure(list(date = c("2022-2-1", "2022-2-2", "2022-2-3", "2022-2-4",
"2022-2-5", "2022-2-6", "2022-2-7", "2022-2-8", "2022-2-9", "2022-2-10",
"2022-2-11", "2022-2-12", "2022-2-13", "2022-2-14", "2022-2-15",
"2022-2-16", "2022-2-17"), pct_change = c(4, 4, 4.04, 4.04, 4.04,
4.44, 4.88, 4.62, 4.8, 5.2, 4.7, 5.06, 4.56, 4.8, 4.32, 4.02,
4.01)), class = "data.frame", row.names = c(NA, -17L))
df1 <- df %>%
mutate_at(vars(-date), funs(./100))
df1 %>%
ggplot(aes(x=as.POSIXct(date), y=pct_change)) +
stat_smooth(
geom = "area",
size = 1,
fill = "red",
color = "red",
alpha = 0.3,
span = .3
) +
coord_cartesian(ylim = c(.04, .0525), expand = FALSE)
It unexpectedly generates the warning messages:
geom_smooth()
using method = 'loess' and formula 'y ~ x' Warning in stats::qt(level/2 + 0.5, pred$df) : NaNs produced
which leads to the area didn't get filled with red color as @zephryl's ouput shown:
How could we solve this issue? Thanks for your help at advance.
Edit 1:
I copy the chuck of code above and run reprex::reprex()
:
> library(ggplot2)
> library(tidyverse)
>
> df <- structure(list(date = c("2022-2-1", "2022-2-2", "2022-2-3", "2022-2-4",
+ "2022-2-5", "2022-2-6", "2022-2-7", "2022-2-8", "2022-2-9", "2022-2-10",
+ "2022-2-11", "2022-2-12", "2022-2-13", "2022-2-14", "2022-2-15",
+ "2022-2-16", "2022-2-17"), pct_change = c(4, 4, 4.04, 4.04, 4.04,
+ 4.44, 4.88, 4.62, 4.8, 5.2, 4.7, 5.06, 4.56, 4.8, 4.32, 4.02,
+ 4.01)), class = "data.frame", row.names = c(NA, -17L))
>
> df1 <- df %>%
+ mutate_at(vars(-date), funs(./100))
>
> df1 %>%
+ ggplot(aes(x=as.POSIXct(date), y=pct_change)) +
+ stat_smooth(
+ geom = "area",
+ size = 1,
+ fill = "red",
+ color = "red",
+ alpha = 0.3,
+ span = .3
+ ) +
+ coord_cartesian(ylim = c(.04, .0525), expand = FALSE)
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
Warning message:
In stats::qt(level/2 + 0.5, pred$df) : NaNs produced
>
> reprex::reprex(style = TRUE)
i Rendering reprex...
√ Reprex output is on the clipboard.
Output:
This reprex appears to crash R. See standard output and standard error for more details.
Standard output and error
Quitting from lines 23-48 (grave-cobra_reprex.spin.Rmd)
Error in curl::curl_fetch_memory(url, handle = handle) :
schannel: failed to receive handshake, SSL/TLS connection failed