determining where an output file when you may want date versioning.
# an output directory in the current project with date versioning in the filename itself
# out = outputter(here::here("output"))
# out("figure1.png")
# an output directory in a temp directory which has versioned subdirectories
out2 = outputter(normalizePath(tempdir(), mustWork = FALSE),datedSubdirectory = TRUE)
#> directing output to: /tmp/RtmpAv5283
out2("figure1.png")
#> /tmp/RtmpAv5283/2026-05-28/figure1.png
out2("supplementary1.xlsx",delete = TRUE)
#> /tmp/RtmpAv5283/2026-05-28/supplementary1.xlsx
# unversioned files in temp directory
out3 = outputter(normalizePath(tempdir(), mustWork = FALSE),datedSubdirectory = FALSE,datedFile = FALSE)
#> directing output to: /tmp/RtmpAv5283
out3("figure1.png")
#> /tmp/RtmpAv5283/figure1.png
# set a range of defaults for graphs
ggrrr::gg_pedantic(font = "Roboto")
#> Warning: The requested font(s): [Roboto], are not present on the system. Alternatives will be used.
#> This warning is displayed once per session.
# Create a graph and save it to a png and pdf with near exact matches in output layout and to fit in a third A4 page
plot = ggplot(diamonds, aes(x=carat,y=price,color = color))+geom_point()+annotate("label",x=2,y=10000,label="Hello")+labs(tag = "A")
tmp = plot %>% gg_save_as(out2("diamonds1"), size = std_size$third)
message("Files were saved as: \n",tmp$png,"\n",tmp$pdf)
#> Files were saved as:
#> /tmp/RtmpAv5283/2026-05-28/diamonds1.png
#> /tmp/RtmpAv5283/2026-05-28/diamonds1.pdf
tmpA simple table
tableExample = diamonds %>%
mutate(size = cut(carat, breaks=c(-Inf,quantile(carat, probs = c(0.25,0.75)),Inf), labels=c("small","medium","large")) %>% as.factor()) %>%
group_by(size,cut) %>%
summarise(
N = n(),
depth = sprintf_list("%1.2f (IQR %1.2f \u2014 %1.2f)", quantile(depth,c(0.5,0.25,0.75))),
price = sprintf_list("%1.0f (IQR %1.0f \u2014 %1.0f)", quantile(price,c(0.5,0.25,0.75)))
)
#> `summarise()` has regrouped the output.
#> ℹ Summaries were computed grouped by size and cut.
#> ℹ Output is grouped by size.
#> ℹ Use `summarise(.groups = "drop_last")` to silence this message.
#> ℹ Use `summarise(.by = c(size, cut))` for per-operation grouping
#> (`?dplyr::dplyr_by`) instead.
tableExample %>% gg_simple_table(font = "Roboto")