Last active
December 17, 2023 01:40
-
-
Save erikerhardt/3c7fa3d0ddb303e927f58fba7d040c0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# path | |
path_original <- setwd(path) | |
on.exit(setwd(path_original), add = TRUE) | |
## Example error capture | |
# First check if effect is involved in interactions | |
check_message <- | |
e_message_capture( | |
emmeans::emmeans( | |
object = fit | |
, specs = var_xs | |
) | |
)(1) | |
if (check_message$logs[[1]]$message == "ERROR MESSAGE") { | |
if(sw_marginal_even_if_interaction) { | |
text_marginal_even_if_interaction <- paste0(check_message$logs[[1]]$message, "\n") | |
message(paste0("e_plot_model_contrasts: Continuing with \"", var_xs, "\" even though involved in interactions.")) | |
} else { | |
message(paste0("e_plot_model_contrasts: Skipping \"", var_xs, "\" since involved in interactions.")) | |
next | |
} | |
} | |
### Logging using log4r | |
# initialize log file | |
log_obj <- | |
e_log_write( | |
sw_init = TRUE | |
, out_path = "." | |
, file_prefix = "out" | |
) | |
# write log entry | |
e_log_write( | |
log_text = "Write this message" | |
, log_obj = log_obj | |
, i_level = 2 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment