• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    R
  • License
    Other
  • Created over 10 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“¦ A template for my research projects, based on the R package structure

Travis-CI Build Status Coverage Status

This repository provides the current template I use for new research projects.

Why an R package structure?

Academic research isn't software development, and there are many other templates for how to organize a research project. So why follow an R package layout? Simply put, this is because the layout of an R package is familiar to a larger audience and allows me to leverage a rich array of tools that don't exist for more custom approaches.

"But"", you say, "a paper doesn't have unit tests, or documented functions! Surely that's a lot of needless overhead in doing this!?"

Exactly...

While there is certainly no need to use all the elements of a package in every research project, or even to have a package that can pass devtools::check() or even devtools::install() for it to be useful. Most generic layout advice starts sounding like an R package pretty quickly: have a directory for data/, a separate one for R/ scripts, another one for the manuscript files, and so forth. Temple Lang and Gentleman (2007) advance the proposal for using the R package structure as a "Research Compendium," an idea that has since caught on with many others.

As a project grows in size and collaboration, having the more rigid structure offered by a package format becomes increasingly valuable. Packages can automate installation of dependencies, perform checks that changes have not broken code, and provide a modular and highly tested framework for collecting together the three essential elements: data, code, and manuscript-quality documentation, in a powerful and feature-rich environment.

Steps to create the template

To use this template, I will usually clone this repo and just remove the .git record, starting off a new project accordingly. Here I document the steps used to set up this template from scratch, which permits a slightly more modular approach. If this were fully automated it would be preferable to copying, but has not yet reached that stage.

The template can be initialized with functions from devtools:

devtools::install_github("hadley/devtools")
library("devtools")

Configure some default options for devtools, see package?devtools:

options(devtools.name = "Carl Boettiger", 
        devtools.desc.author = "person('Carl', 'Boettiger', email='[email protected]', role = c('aut', 'cre'))",
        devtools.desc.license = "MIT + file LICENSE")

Run devtools templating tools

setup()
use_testthat()
use_vignette("intro")
use_travis()
use_package_doc()
use_cran_comments()
use_readme_rmd()

Additional modifications and things not yet automated by devtools:

  • Add the now-required LICENSE template data
  • add covr to the suggests list
writeLines(paste("YEAR: ", format(Sys.Date(), "%Y"), "\n", 
                 "COPYRIGHT HOLDER: ", getOption("devtools.name"), sep=""),
           con="LICENSE")

use_package("covr", "suggests")

write(
"
r_binary_packages:
  - testthat
  - knitr

r_github_packages:
  - jimhester/covr

after_success:
  - Rscript -e 'library(covr); coveralls()'",
file=".travis.yml", append=TRUE)

Further steps that aren't automated

Further steps aren't yet automated in devtools or by me; as it's easier to add these manually to the template and then use the template when starting a new project.

  • add the travis shield to README, (as prompted to do by add_travis())
  • Turn on repo at coveralls.io and add the shield to README
  • adding additional dependencies to DESCRIPTION with use_package, and also add to .travis.yml manually, e.g. under r_binary_packages:, r_github_packages, or r_packages
  • add additional data with use_data() or possibly use_raw_data() (for scripts that import and clean data first)

Manuscript elements

  • Recent developments in rmarkdown, knitr and rticles packages greatly faciliates using vignettes as full manuscripts. The above step adds only a basic HTML templated vignette. This package includes a template for a latex/pdf manuscript using these tools. The actual template appropriate for a project may be better selected from (possibly my fork of) the rticles templates.

More Repositories

1

knitcitations

πŸ“¦ Generate citations for knitr markdown and html files
R
217
star
2

hugo-now-ui

🌐 Hugo adaptation of Now-UI from Creative Tim
CSS
98
star
3

labnotebook

πŸ““ Source code and version history for my online lab notebook
HTML
97
star
4

noise-phenomena

πŸ““ Ecology Letters review paper: Noise-driven phenomena in population biology
TeX
49
star
5

contentid

πŸ“¦ R package for working with Content Identifiers
R
44
star
6

nonparametric-bayes

πŸ““ Non-parametric Bayesian Inference for Conservation Decisions
TeX
41
star
7

s3-log-parse

Parsing access logs from S3
Python
21
star
8

quarto-hugo-material-dashboard

Adapting material-dashboard to Quarto and Hugo
SCSS
17
star
9

bad-forecast-good-decision

πŸ““ Utility provides a more meaningful measure of forecast skill than goodness-of-fit
TeX
16
star
10

socialR

functions for making R interact with social media
R
15
star
11

compendium

πŸ““ Project Name Here
12
star
12

dockermachine

Simple wrapper around docker-machine tool for creating and managing cloud instances across many providers
R
11
star
13

pdg_control

πŸ““ Pretty Darn Good Control: applications in optimal control
R
10
star
14

birddb

Import and query all of eBird locally
R
9
star
15

earlywarning

πŸ““ Methods for detecting early warning signals of critical transitions
R
9
star
16

schemar

πŸ“¦ Create Structured Data Using the Schema.org Vocabulary
R
8
star
17

berkeley-linux-config

πŸ–₯️ Linux needs are not always well documented by campus IT. Here are some solutions that worked for me, PR's welcome.
TeX
6
star
18

hugo-material

🌐 Hugo theme building on Bootstrap Material Kit
CSS
6
star
19

neonstore

πŸ“¦ A local content-based storage system for NEON data
R
6
star
20

taxalight

A lightning-fast taxonomic database store backed by LMDB
R
5
star
21

eml2

πŸ“¦ A list-based rewrite of higher-level functions from EML
5
star
22

structured-populations

πŸ“¦ Stochastic Population Dynamics in Ecology with Age and Stage Structure
C
5
star
23

codemeta

πŸ“¦ A smaller codemetar
R
5
star
24

whiskey

Jekyll-based template for Bourbon+Neat+Bitters+Refills SASS
CSS
5
star
25

decisions-vs-transients

πŸ““
TeX
4
star
26

rdftools

πŸ“¦ Common utilities for RDF. Package has helper routines only, limited stand-alone use.
R
4
star
27

mcmcTools

tools for Markov Chain Monte Carlo in R
R
3
star
28

wrightscape

πŸ“¦ Infer adaptive landscapes from phylogenetic trees
R
3
star
29

nexld

πŸ“¦ Working with NeXML as JSON-LD
R
3
star
30

cron-container

Run an R script as a cron job using Docker
Dockerfile
3
star
31

populationdynamics

πŸ“¦ Tools to simulate various population dynamics models in ecology
C
3
star
32

regimeshifts

πŸ“¦ R package providing simulations and data from ecological regime shifts
R
3
star
33

dissertation

TeX
2
star
34

minioclient

R Interface to the MINIO client
R
2
star
35

forecasts-darts-framework

Experimental example workflows with the darts framework
Jupyter Notebook
2
star
36

AdaptiveDynamics

πŸ“¦ Individual based simulations of adaptive dynamics
TeX
2
star
37

prosecutors-fallacy

πŸ““ Migrated from the prosecutor branch of my earlywarning repository
2
star
38

example-notebooks

because repos are actually better than gists
Jupyter Notebook
2
star
39

ptagir

R interface to the ptagis database of tagged fish
2
star
40

duckdbfs

Simple wrappers for duckdb to open local and remote filesystems
R
2
star
41

config

Machine confuration tweaks
2
star
42

ews-review

πŸ““ Early warning signals review mansucript
PostScript
2
star
43

pmc

πŸ“¦ Phylogenetic Monte Carlo: Quantifying Uncertainty in Phylogenetic Methods (now on CRAN)
R
2
star
44

warningsignals

πŸ““
R
2
star
45

bs-tipping

πŸ““ paper on state tipping vs bifurcation tipping
R
2
star
46

multiple_uncertainty

πŸ““
R
2
star
47

eco4cast-dashboard-material

A dashoard using my material theme
SCSS
2
star
48

prov

An index for a data store, permitting generation and querying of schema.org, prov, dcat dataset descriptions
R
2
star
49

sandbox

miscellaneous scripts and scratchpads
R
2
star
50

nimbios-transients

Example data that may or may not contain transients
PostScript
2
star
51

hugo-material-theme

🌐 Hugo port of Creative Tim Material Kit
CSS
2
star
52

piggyback-tests

πŸ—„οΈ A repository for testing the piggyback R package
1
star
53

rgbif_mcglinn

R
1
star
54

fluctuationDomains

πŸ““ Code for "Fluctuation Domains in Adaptive Evolution", published in TPB
TeX
1
star
55

forecasting-limits

πŸ““
1
star
56

bin

handy binaries
Python
1
star
57

website

SCSS
1
star
58

rdbms-tutorial

Relational Database Management System Tutorial in R
1
star
59

talks-2018-pointblue

🎀
HTML
1
star
60

openscience-whitepaper

Open Science: Balancing Individual Incentives with Common Good
TeX
1
star
61

2015

Lab notebook for 2015
HTML
1
star
62

quarto-hugo

a reprex of the bug really
HTML
1
star
63

fortran

πŸ“¦ Minimal demo for R interface to FORTRAN
C
1
star
64

debug-windows

R
1
star
65

quarto-material

CSS
1
star
66

hugo-cover-theme

A hugo theme / template based on bootstrap Cover example
HTML
1
star
67

movebank

πŸ“¦ A lightweight interface to the movebank API
R
1
star