Skip to content

Commit

Permalink
new fuction plot_diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavjack committed Jul 9, 2024
1 parent 3f2d53f commit 4763661
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
24 changes: 21 additions & 3 deletions R/remove_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
#' rmout <- potato %>%
#' remove_outliers(data = .
#' , formula = stemdw ~ 0 + (1|bloque) + treat*geno
#' , plot_diag = FALSE
#' )
#'
#' rmout
#'

remove_outliers <- function(data
, formula
, drop_na = TRUE
, drop_na = FALSE
, plot_diag = FALSE
) {

Expand Down Expand Up @@ -100,11 +101,28 @@ remove_outliers <- function(data
relocate({{trait}}, .after = last_col())

modelf <- lme4::lmer(formula = formula, data = nwdt)

diagplot <- if(isTRUE(plot_diag)) {

raw <- data %>%
plot_diagnostic(formula) %>%
cowplot::plot_grid(nrow = 1, plotlist = ., labels = "Raw data")

clean <- nwdt %>%
plot_diagnostic(formula) %>%
cowplot::plot_grid(nrow = 1, plotlist = ., labels = "Clean data")

list(raw, clean) %>%
cowplot::plot_grid(nrow = 2, plotlist = .)

} else { NULL }


list(
data = nwdt
data = list(raw = data, clean = nwdt)
, outliers = outliers
, diagplot = diagplot
, model = list(raw = model, clean = modelf)
)

}
3 changes: 2 additions & 1 deletion man/remove_outliers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4763661

Please sign in to comment.