I have the following dataset:
structure(list(media = c(56.257, NA, NA,
56.256, 56.267, NA, NA, 56.265, 56.262, 56.259, 56.265,
56.263, 56.265, 56.262, 56.264, NaN, 56.268, 56.265, 560.26,
5600.2, 56.265, 56.262, 56.263, 56.264, 56.263, 56.265, 56.271,
56.271, 56.28, 56.281), cycle_rounded = structure(c(1604487600,
1604487600, 1604487600, 1604487600, 1604487600, 1604487600, 1604487600,
1604487600, 1604487600, 1604487600, 1604487600, 1604487600, 1604487600,
1604487600, 1604487600, 1604487600, 1604487600, 1604487600, 1604487600,
1604487600, 1604487600, 1604487600, 1604487600, 1604487600, 1604487600,
1604487600, 1604487600, 1604487600, 1604489400, 1604489400), class = c("POSIXct",
"POSIXt"), tzone = "UTC")), row.names = c(NA, -30L), class = c("data.table",
"data.frame"), .internal.selfref = <pointer: 0x000001d9d6a21f90>)
I would like to 1) Get values in media variable, above and below the IQR (interquartile range - outliers) of all values in media and convert them to NaN. 2) Convert NA to NaN, because when I will plot geom_line() it automatically gives me a break in the line, that is what I need.
I try something like it: mutate(media = case_when(media > 1.5*IQR(media, na.rm = T) ~ NaN)) But won't works.
Thanks for appreciate all help.