{{{preamble}}}
{{{package}}} is an example research compendium, created by MATSS
, version {{{version}}}; ({{{citation_txt}}}).
The organization of this project follows the recommendations for a research compendium (Marwick, Boettiger, Mullen 2018 "Packaging Data Analytical Work Reproducibly Using R (and Friends)").
The initial contents are:
{{{package}}}
├── {{{package}}}.Rproj
├── DESCRIPTION
{{{license_file_contents}}}├── NAMESPACE
├── README.md
├── R
│ └── analysis_functions.R
└── analysis
├── pipeline.R
├── references.bib
└── report.Rmd
with the R
subfolder containing function definitions for the data analysis, and the analysis
subfolder containing the files for the analysis itself:
analysis/pipeline.R
defines the drake
workflow
analysis/report.Rmd
is the Rmarkdown file containing the results of the analysis
* analysis/references.bib
contains the references for report.Rmd
and is instantiated with one reference for the MATSS
package.
?usethis::use_mit_license()
devtools
package:devtools::install(".") # in the working directory of this compendium
Restart R. After installing the new package, you will need to restart R. (If you are working within RStudio, this should happen automatically if you use the "Build and Install" button.)
Source the analysis script.
analysis/pipeline.R
contains the main workflow. Within RStudio, you can use the "Source" button and/or the keyboard shortcut (Control + Shift + s; or Command + Shift + s on Mac).
Otherwise, within an R console:
source("analysis/pipeline.R")
analysis/report.Rmd
contains the Rmarkdown source for reporting and plotting the results of the analysis.
After compilation, There should be an html version (analysis/report.html
) that is viewable within a web browser directly, and a markdown version (analysis/report.md
) that is viewable within a text editor, but shows formatting when uploaded to GitHub.MATSS
provides access to many additional datasets through retriever, which downloads the datasets directly to your machine. The below steps are intended to provide the shortest path to a working setup, though you may need additional configurtion if you have an existing python setup.
reticulate
R package). library(reticulate)
py_available(initialize = TRUE)
retriever
. if (!py_module_available("retriever"))
{
py_install("retriever")
}
If this fails, then it may be easier to setup a miniconda environment for installing retriever
instead.
install_miniconda()
py_install("retriever")
# development version on github:
# py_install("git+git://github.com/weecology/retriever@master", pip = TRUE)
rdataretriever::get_updates()
MATSS::use_default_data_path(<path>) # e.g. <path> = "~/data"
download_datasets()
, which can be used to download some or all of the supported datasets: MATSS::download_datasets()
Write your own analysis functions.
You can add these to the file R/analysis_functions.R
or add additional .R
files in that folder.
If you use other packages in these methods, be sure to include them among the dependencies for your compendium with usethis::use_package()
.
To add documentation you can follow the existing examples, or read more in detail at http://r-pkgs.had.co.nz/man.html#man-functions
Update the pipeline script.
In analysis/pipeline.R
, you will want to modify the methods
drake plan to include the new functions you just added. (and possibly replacing the existing ones)
Add code to process and plot the results.
In analysis/report.Rmd
, you will want to modify the code to read in the new results, process the output, and construct plots.
MATSS
compendia are designed to be easily distributible via code-sharing platforms, such as Github. An example compendium, built using the latest version of MATSS
can be found at https://github.com/weecology/MATSSdemo.
A guide to setting up Git and getting the compendium uploaded to Github is in this chapter of Hadley Wickham's book on R packages.
For a more extensive resource on using Git and Github as part of your coding workflow, see Happy Git and GitHub for the useR.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.