Systematically save your figures for your report
save_figures(
figure,
list_figures,
header = "",
footnotes = "",
filename0 = "x",
cnt_chapt_content = "001",
cnt = 1,
path = NULL,
width = 6,
height = 6,
output_type = c("pdf", "png"),
type = "Figure",
alttext = "",
filename_desc = "",
nickname = "",
raw = NULL,
message = FALSE
)
The figure you would like to be saved.
The list where all figures will be saved.
The name and title of the figure. Default = "".
Any footnote you want attached to this figure.
The filename set at the begining of the chapter.
The order number that this exists in the chapter.
The figure number.
The path the file needs to be saved to. Default = "NULL", meaning it wont save anything and will override all other saving elements.
Default = 6 inches.
Default = 6 inches.
Default = c("pdf", "png"). Can be anything supported by ggsave().
Default = "Figure", but can be anything that the element needs to be called (e.g., "Graphic", "Fig.", "Graph") to fit in the phrase "Figure 1. This is my plot!".
String with what the alternative text is.
Additional description text for the filename that will be added at the name of file before the filename extention. Can be use to add a species name, location, or anything else that would make it easier to know what that file shows.
A unique name that can be used to identify the figure so it can be referenced later in the report.
Optional. The data.frame or other data that has no rounding and no dividing of numbers (good to save this for record keeping) and was used to create the figure. Default = NA.
TRUE/FALSE. Default = FALSE. If TRUE, it will print information about where your plot has been saved to.
list_figures updated with the new plot and metadata.
library(magrittr)
library(ggplot2)
list_figures <- c()
dat <- data.frame(x = rnorm(n = 10),
y = rnorm(n = 10),
col = rep_len(x = c("a", "b"),
length.out = 5))
# Select data and make plot
figure<- dat %>%
ggplot(aes(x = x, y = y,
colour = as.factor(col))) + # create plot
geom_point()
list_figures<-save_figures(figure = figure,
list_figures = list_figures,
header = "example",
footnote = "footnote example")
names(list_figures)
#> [1] ""
list_figures
#> [[1]]
#> [[1]]$caption
#> [1] "Figure [1](){#}. -- example.^[footnote example]"
#>
#> [[1]]$header
#> [1] "Figure [1](){#}. -- example."
#>
#> [[1]]$nickname
#> [1] ""
#>
#> [[1]]$alttext
#> [1] ""
#>
#> [[1]]$number
#> [1] 1
#>
#> [[1]]$footnotes
#> [1] "footnote example"
#>
#> [[1]]$filename
#> [1] "001_fig_1"
#>
#>