Creates an R Markdown (.Rmd) report from a template to explore and
summarize user data. User can modify this report and use the function
rmarkdown::render() (or click the Render of the RStudio IDE) to convert
this .Rmd in different formats:
HTML document (
output_format = "bookdown::html_document2");PDF document (
output_format = "bookdown::pdf_document2");Word document (
output_format = "bookdown::word_document2");HTML, PDF and Word documents (
output_format = "all").
Usage
fb_make_report(
path = ".",
filename = NULL,
title = NULL,
author = NULL,
species_traits,
site_species,
site_locations,
species_categories = NULL,
overwrite = FALSE,
open = TRUE,
interactive = TRUE
)Arguments
- path
a
characterof length 1. The directory in which the.Rmdand.rdsfiles will be created. This directory must exist. Note that subdirectoriesfunbiogeo/andfunbiogeo/data/will be created. Default is the current directory.- filename
a
characterof length 1. The name of the.Rmdfile to be created. IfNULL(default) the.Rmdfile will be named from thetitle(if provided) orfunbiogeo_report.Rmdotherwise.- title
a
characterof length 1. The title of the report. IfNULL(default) the title will be named from thetitle(if provided) orfunbiogeo Reportotherwise.a
characterof length 1. The author(s) of the report. IfNULL(default) no author will be added.- species_traits
a
data.framewith species in rows and traits as columns. NOTE: The first column should be named"species"and contain species names. The other columns should be named according to trait names.- site_species
a
data.framewith sites in rows and species in columns. NOTE: the first column should be named"site"and indicate site names. The other columns should be named according to species names.- site_locations
an
sfobject with the spatial geometries of sites. NOTE: the first column should be named"site"and indicate site names.- species_categories
(default =
NULL) 2-columnsdata.framegiving species categories, with the first column describing the species name, and the second column giving their corresponding categories- overwrite
a logical. If the
.Rmdfile (or any.rdsdataset) is already present andoverwrite = TRUE, the.Rmdfile (and all.rdsfiles) will be replaced. Default isFALSE.- open
a logical. If
TRUE(default), the.Rmdfile will be opened in the text editor.- interactive
a logical. If
TRUE(default), the function will ask user to accept the copy of datasets.
Details
Note that a copy of user data will be saved as .rds files in
path/funbiogeo/data/ (where path is the directory defined by the user).
Examples
if (FALSE) { # \dontrun{
# Create temporary folder (optional) ----
temp_path <- tempdir()
# Create report ----
fb_make_report(
path = temp_path,
author = "Casajus N. and Grenié M.",
species_traits = woodiv_traits,
site_species = woodiv_site_species,
site_locations = woodiv_locations,
open = FALSE
)
# Open Rmd file ----
utils::file.edit(file.path(temp_path, "funbiogeo", "funbiogeo_report.Rmd"))
# Render Rmd file ----
rmarkdown::render(
input = file.path(temp_path, "funbiogeo", "funbiogeo_report.Rmd"),
output_format = "all"
)
} # }
