# NOT RUN {
library(AirSensor)
# Single day subset
pat <-
example_pat %>%
pat_filterDate(20180813, 20180814)
# Two Sample Student T-Test (advanced users only - see details.)
FUN_ttest <- function(x) {
result <- try({
hourly_ttest <- stats::t.test(x$pm25_A, x$pm25_B, paired = FALSE)
tbl <- dplyr::tibble(
t_score = as.numeric(hourly_ttest$statistic),
p_value = as.numeric(hourly_ttest$p.value),
df_value = as.numeric(hourly_ttest$parameter)
)
}, silent = TRUE)
if ( "try-error" %in% class(result) ) {
tbl <- dplyr::tibble(
t_score = as.numeric(NA),
p_value = as.numeric(NA),
df_value = as.numeric(NA)
)
}
return(tbl)
}
t.testStats <-
pat %>%
pat_extractData() %>% # Note: Extract the timeseries data.frame
patData_aggregate(FUN_ttest)
head(t.testStats)
# }
Run the code above in your browser using DataLab