# Get sheet namessheet_names <-excel_sheets(excel_file)# Function to read each sheet with some warning suppressionread_sheet_safe <-function(sheet) {suppressMessages(suppressWarnings(read_excel(excel_file, sheet = sheet, .name_repair ="universal", guess_max =10000) ) )}# Read all sheetsresults <-map(sheet_names, safely(read_sheet_safe))names(results) <- sheet_names# Identify sheets that failed to import (have only charts/figures)failed_sheets <-names(results)[map_lgl(results, ~!is.null(.x$error))]print(failed_sheets)
character(0)
# Exclude sheets with only charts/figuresvalid_sheets <-setdiff(sheet_names, failed_sheets)# Read only sheets with dataall_data <-map(valid_sheets, read_sheet_safe) %>%set_names(valid_sheets)
Warning in full_join(dat %>% select(date = wl_date, water_level, wl_loess), : Detected an unexpected many-to-many relationship between `x` and `y`.
ℹ Row 1052 of `x` matches multiple rows in `y`.
ℹ Row 321 of `y` matches multiple rows in `x`.
ℹ If a many-to-many relationship is expected, set `relationship =
"many-to-many"` to silence this warning.
Warning in full_join(dat %>% select(date = wl_date, water_level, wl_loess), : Detected an unexpected many-to-many relationship between `x` and `y`.
ℹ Row 1051 of `x` matches multiple rows in `y`.
ℹ Row 317 of `y` matches multiple rows in `x`.
ℹ If a many-to-many relationship is expected, set `relationship =
"many-to-many"` to silence this warning.
for (well innames(all_monitor_data)) { dat <- all_monitor_data[[well]]print(plot_dual_y(dat, well))}
Warning: No shared levels found between `names(values)` of the manual scale and the
data's shape values.
Warning: Removed 98 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: No shared levels found between `names(values)` of the manual scale and the
data's shape values.
Warning: Removed 1040 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: No shared levels found between `names(values)` of the manual scale and the
data's shape values.
Removed 1040 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: No shared levels found between `names(values)` of the manual scale and the
data's shape values.
Warning: Removed 1069 rows containing missing values or values outside the scale range
(`geom_point()`).
Chloride vs. Time Nonparametric Correlations - Kendall tau-b, Monitoring Wells, Period of Record
Date mw4 mw20 mw21 mw25
Correlation-coffecient "1.000" "0.154" "0.686" "-0.325" "0.502"
Sig (1 sided) "0.000" "0.000" "0.000" "0.000" "0.000"
N "236" "320" "320" "316" "342"
Chloride vs. Time Nonparametric Correlations- Kendall Tau-b, Monitoring Wells, 2018-2022
# Well labels for outputwell_labels <-c("MW-4", "MW-20", "MW-21", "MW-25")well_names <-names(all_monitor_data)# Prepare results matrixresult_mat <-matrix(NA, nrow =3, ncol =length(well_names) +1)colnames(result_mat) <-c("Date", well_labels)rownames(result_mat) <-c("Correlation-coefficient", "Sig (1 sided)", "N")# Combine all dates for the Date columnall_dates <-unique(unlist(lapply(all_monitor_data, function(x) x$date)))filtered_dates <- all_dates[all_dates >=as.Date("2018-01-01") & all_dates <=as.Date("2022-12-31")]result_mat[ , "Date"] <-c("1.000", "0.000", as.character(length(filtered_dates)))# Loop through each monitoring wellfor (i inseq_along(well_names)) { dat <- all_monitor_data[[well_names[i]]] %>%filter(date >=as.Date("2018-01-01") & date <=as.Date("2022-12-31")) %>%select(date, chloride) %>% tidyr::drop_na()if (nrow(dat) >=2) { res <-cor.test(x =as.numeric(dat$date),y = dat$chloride,method ="kendall",exact =FALSE ) result_mat["Correlation-coefficient", i+1] <-sprintf("%.3f", as.numeric(res$estimate)) result_mat["Sig (1 sided)", i+1] <-formatC(res$p.value, format ="f", digits =3) result_mat["N", i+1] <-as.character(nrow(dat)) } else { result_mat["Correlation-coefficient", i+1] <-NA result_mat["Sig (1 sided)", i+1] <-NA result_mat["N", i+1] <-as.character(nrow(dat)) }}print(result_mat)
Date MW-4 MW-20 MW-21 MW-25
Correlation-coefficient "1.000" NA "0.497" "0.396" "-0.418"
Sig (1 sided) "0.000" NA "0.000" "0.000" "0.000"
N "113" "0" "60" "57" "57"