COMPASS-DOE / TEMPEST-1-porewater

Data analysis & manuscript prep for the first year of porewater data after TEMPEST 1.0
MIT License
0 stars 0 forks source link

TSLA function not working #9

Open amyerspigg opened 1 month ago

amyerspigg commented 1 month ago

https://github.com/COMPASS-DOE/TEMPEST-1-porewater/blob/53f892c60a0f508dd230e24239136c4217cb9d1e/scripts/analysis_scripts/1_manuscript_analysis_porewaterDOC.Rmd#L279

error:

Error in mutate(): ℹ In argument: max_effect_Mid = case_when(...). Caused by error in case_when(): ! Failed to evaluate the left-hand side of formula 1. Caused by error: ! object 'avg_Mid' not found Backtrace:

  1. global calc_dist_metrics(pw_ft, flood_event_datetime, c("relabund"))
    1. dplyr::case_when(...)
    2. dplyr:::case_formula_evaluate(...)
    3. rlang::eval_tidy(pair$lhs, env = default_env) Error in mutate(., max_effect_Mid = case_when(avg_Mid > avg_Pre ~ max_Mid, :

Caused by error in case_when(): ! Failed to evaluate the left-hand side of formula 1. Caused by error: ! object 'avg_Mid' not found

I checked and there should be data for the mid-point (at least one timepoint) so not sure what's going on

amyerspigg commented 1 month ago

@stephpenn1

stephpenn1 commented 1 month ago

This error is happening because your data frame pw_ft doesn't have any during-event ("Mid") data points. So it cannot execute the line

mutate(max_effect_Mid = case_when(
      avg_Mid > avg_Pre ~ max_Mid,
      avg_Mid < avg_Pre ~ min_Mid,
      avg_Mid == avg_Pre ~ avg_Mid
    ))