Skip to content

Commit

Permalink
fix plot diag
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavio Lozano Isla committed Jul 6, 2024
1 parent 2eb004a commit f79047d
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ VignetteBuilder: knitr
License: GPL-3 | file LICENSE
LazyData: true
Encoding: UTF-8
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ importFrom(shiny,runGadget)
importFrom(stats,anova)
importFrom(stats,aov)
importFrom(stats,as.formula)
importFrom(stats,density)
importFrom(stats,fitted)
importFrom(stats,lm)
importFrom(stats,median)
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# inti 0.6.6

- Package
- Update function to remove outliers => "`remove_outliers`"
- Update function to outliers_remove => "`remove_outliers`"
- Update function `plot_diag()`

- Rticles
- Fix Tables and Figures order in final document
Expand Down
6 changes: 3 additions & 3 deletions R/gdoc2qmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ gdoc2qmd <- function(file

tab <- txt %>%
dplyr::filter(grepl("^\\|", .data$value) | grepl("#tbl", .data$value)) %>%
ungroup() %>%
mutate(group = case_when(
dplyr::ungroup() %>%
dplyr::mutate(group = case_when(
grepl("#tbl", .data$value) ~ .data$name
)) %>%
tidyr::fill(., group, .direction = "up") %>%
tidyr::fill(., .data$group, .direction = "up") %>%
split(.$group) %>%
purrr::map_dfr(~ slice(.data = ., c(n(), 1:(n()-1)))) %>%
split(.$group) %>%
Expand Down
10 changes: 6 additions & 4 deletions R/plot_diag.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
#'
#' @return plots
#'
#' @importFrom stats density
#'
#' @export
#'
#' @examples
#'
#' \dontrun{
#'
#' dt <- potato
#' library(inti)
#'
#' lm <- aov(stemdw ~ bloque + geno*treat, dt)
#' lm <- aov(stemdw ~ bloque + geno*treat, data = potato)
#'
#' #lm <- lme4::lmer(stemdw ~ bloque + (1|geno:treat), dt)
#' #lm <- lme4::lmer(stemdw ~ bloque + (1|geno:treat), data = potato)
#'
#' plot(lm, which = 1)
#' plot_diag(lm)[3]
Expand Down Expand Up @@ -52,7 +54,7 @@ plot_diag <- function( model, title = NA) {

# Histogram
p1 <- ggplot(dt , aes(.data$.resid)) +
geom_histogram(aes(y = after_stat(density)),
geom_histogram(aes(y = ggplot2::after_stat(density)),
color = "black", fill = "grey82", bins = 30) +
stat_function(fun = stats::dnorm, color = "blue", args = list(mean = 0, sd = sd(dt$.resid))) +
theme_bw() +
Expand Down
13 changes: 6 additions & 7 deletions R/remove_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#' Function to remove outliers in MET experiments
#'
#' @param data Experimental design data frame with the factors and traits.
#' @param trait Name of the trait.
#' @param model The fixed or random effects in the model.
#' @param formula mixed model formula.
#' @param drop_na drop NA values from the data.frame
#' @param plot_diag Diagnostic plot based in the raw and clean data
#'
#' @description
#'
Expand All @@ -30,11 +30,10 @@
#'
#' library(inti)
#'
#' rmout <- remove_outliers(
#' data = potato
#' , formula = stemdw ~ 0 + (1|bloque) + treat*geno + geno
#' rmout <- remove_outliers(data = potato
#' , formula = stemdw ~ 0 + (1|bloque) + treat*geno
#' , drop_na = FALSE
#' , plot_diag = TRUE
#' , plot_diag = FALSE
#' )
#'
#' rmout
Expand All @@ -47,7 +46,7 @@ remove_outliers <- function(data
) {

# data = potato; drop_na = TRUE; plot_diag = TRUE
# formula = stemdw ~ 0 + (1|bloque) + treat*geno+ geno
# formula = stemdw ~ 0 + (1|bloque) + treat*geno

out_flag <- bholm <- NULL

Expand Down
6 changes: 3 additions & 3 deletions man/plot_diag.Rd

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

13 changes: 6 additions & 7 deletions 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 f79047d

Please sign in to comment.