View source: R/library--data_prep--filter_tools--sd_trend_outlier.R
Flag_From_Trend | R Documentation |
Flag values as outliers based on error from estimated trend This function can be done within group if the data fed into it was grouped
Flag_From_Trend(DF, base_data, trend_data, sd_degree = 2.5)
DF |
Dataframe containing selected columns |
base_data |
Name of column containing Raw data |
trend_data |
Name of generated trend data |
sd_degree |
Threshold to flag deviant values as an outlier |
DF with a new column 'flagged_outlier' that contains if the column is an outlier
library(dplyr)
data("Example_data", package = "Covid19Wastewater")
smoothing_df <- Example_data%>%
select(site, date, N1, N2)%>%
filter(N1 != 0, N2 != 0)%>%
mutate(N1 = log(N1), N2 = log(N2), N12_avg = (N1 + N2) / 2)
df_data <- loessSmoothMod(smoothing_df, "N12_avg", "N12_avg_loess", Filter = NULL)
head(df_data%>%
group_by(site)%>%
Flag_From_Trend( N12_avg, N12_avg_loess)%>%
select(site, date, N12_avg, flagged_outlier))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.