data_fails <- tibble::tibble(
EMS_ID = c("0200016", "0200016", "0200016", "0200016", "0200016"),
Station = c("ELK RIVER ABOVE HIGHWAY 93",
"ELK RIVER ABOVE HIGHWAY 93","ELK RIVER ABOVE HIGHWAY 93",
"ELK RIVER ABOVE HIGHWAY 93",
"ELK RIVER ABOVE HIGHWAY 93"),
Variable = c("Aluminum Total",
"Aluminum Total","Aluminum Total","Aluminum Total","Aluminum Total"),
Code = c("AL-T", "AL-T", "AL-T", "AL-T", "AL-T"),
Value = c(0.031, 0.0192, 0.397, 0.0183, 0.1),
Units = c("mg/L", "mg/L", "mg/L", "mg/L", "mg/L"),
DetectionLimit = c(0.5, 0.5, 0.5, 0.5, 0.5),
ResultLetter = c(NA, NA, NA, NA, NA),
Date = c("2020-01-05","2020-01-27",
"2020-02-02","2020-02-17","2020-03-01"),
Outlier = c(FALSE, FALSE, FALSE, FALSE, FALSE),
Site_Renamed = c("ELK RIVER ABOVE HIGHWAY 93",
"ELK RIVER ABOVE HIGHWAY 93","ELK RIVER ABOVE HIGHWAY 93",
"ELK RIVER ABOVE HIGHWAY 93",
"ELK RIVER ABOVE HIGHWAY 93"),
UPPER_DEPTH = as.factor(c(NA, NA, NA, NA, NA)),
Detected = as.factor(c("FALSE", "FALSE", "FALSE", "FALSE", "FALSE")),
Timeframe = as.factor(c("2020", "2020", "2020", "2020", "2020"))
)
wqbc::summarise_wqdata(
data_fails,
by = c("EMS_ID"),
censored = TRUE,
na.rm = TRUE
)
Error in names(ret) <- c("mean", "se", LCL(x), UCL(x)) :
'names' attribute [4] must be the same length as the vector [0]
In addition: Warning message:
In survreg.fit(X, Y, weights, offset, init = init, controlvals = control, :
Ran out of iterations and did not converge
Backtrace:
▆
1. └─wqbc::summarise_wqdata(...)
2. └─plyr::ddply(...)
3. └─plyr::ldply(...)
4. └─plyr::llply(...)
5. ├─plyr:::loop_apply(n, do.ply)
6. └─plyr `<fn>`(1L)
7. └─wqbc .fun(piece, ...)
8. ├─base::mean(ml)
9. └─NADA::mean(ml)
10. └─NADA .local(x, ...)
Two examples using the same EMS_ID/Station but different parameters/variables and in one case the function
summarize_wqdata()works and provides a summary table while in the other case the table throws an errorExample where it works properly
Output
Example where it fails
Output