Skip to content

Instantly share code, notes, and snippets.

@bhive01
Created May 15, 2020 15:23
Show Gist options
  • Save bhive01/e293135e904745a129165794bd4c0032 to your computer and use it in GitHub Desktop.
Save bhive01/e293135e904745a129165794bd4c0032 to your computer and use it in GitHub Desktop.
#library(agricolae)
#library(openxlsx)
#library(readxl)
#library(fs)
#library(broom)
#library(Hmisc)
#library(janitor)
#library(lubridate)
#library(patchwork) # devtools::install_github("thomasp85/patchwork")
library(ggtext) #remotes::install_github("wilkelab/ggtext")
#library(ggbiplot) # devtools::install_github("vqv/ggbiplot")
#library(missMDA)
library(tidyverse)
#library(viridis)
library(here)
create_dirs <-
function(df){
pwalk(list(df$COMNM, df$LCCD, df$TRLID, df$MATNM), ~fs::dir_create(here("DEVoutputs", glue::glue("{..1}"), glue::glue("{..2}"), glue::glue("{..3}"), glue::glue("{..4}"))))
return(df)
}
render_one <- function(df, COMNM, LCCD, TRLID) {
rmarkdown::render(
here('PerTrialReportDev.Rmd'),
output_file = here("DEVoutputs", glue::glue("{COMNM}"), glue::glue("{LCCD}"), glue::glue("{TRLID}"), glue::glue("{LCCD}_{TRLID}_Experiment_Data_Summary.html")),
params = list(TRLID = TRLID, input_data = df, trial_description = glue::glue("{LCCD}_{COMNM}-{TRLID}"))
)
}
render_html_reports <- function(df) {
df %>%
nest(trl_data = -c(SPECIES, COMNM, LCCD, TRLID)) %>%
{pwalk(list(.$trl_data, .$COMNM, .$LCCD, .$TRLID), ~render_one(..1, ..2, ..3, ..4))}
return(df)
}
moa <- readRDS("Csegfault.rds")
moa %>%
#slice(c(1,2)) %>%
create_dirs(.) %>%
render_html_reports(.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment