Git Product home page Git Product logo

rrtools's Introduction

rrtools: Tools for Writing Reproducible Research in R

R-CMD-check Launch Rstudio Binder

Motivation

The goal of rrtools is to provide instructions, templates, and functions for making a basic compendium suitable for writing a reproducible journal article or report with R. This package documents the key steps and provides convenient functions for quickly creating a new research compendium. The approach is based on Marwick (2017), Marwick et al. (2018), and Wickham’s (2017) work using the R package structure as the basis for a research compendium.

rrtools provides a template for doing scholarly writing in a literate programming environment using Quarto, an open-source scientific and technical publishing system. It also allows for isolation of your computational environment using Docker, package versioning using renv, and continuous integration using GitHub Actions. It makes a convenient starting point for writing a journal article or report.

The functions in rrtools allow you to use R to easily follow the best practices outlined in several major scholarly publications on reproducible research. In addition to those cited above, Wilson et al. (2017), Piccolo & Frampton (2016), Stodden & Miguez (2014) and rOpenSci (2017) are important sources that have influenced our approach to this package.

Installation

To explore and test rrtools without installing anything, click the Binder badge above to start RStudio in a browser tab that includes the contents of this GitHub repository. In that environment you can browse the files, install rrtools, and make a test compendium without altering anything on your computer.

You can install rrtools from GitHub with these lines of R code (Windows users are recommended to install a separate program, Rtools, before proceeding with this step):

if (!require("devtools")) install.packages("devtools")
devtools::install_github("benmarwick/rrtools")

How to use

To create a reproducible research compendium step-by-step using the rrtools approach, follow these detailed instructions. We use RStudio, and recommend it, but is not required for these steps to work. We recommend copy-pasting these directly into your console, and editing the options before running. We don’t recommend saving these lines in a script in your project: they are meant to be once-off setup functions.

0. Create a Git-managed directory linked to an online repository

  • It is possible to use rrtools without Git, but usually we want our research compendium to be managed by the version control software Git. The free online book Happy Git With R has details on how to do this. In brief, there are two methods to get started:
    • New project on GitHub first, then download to RStudio: Start on Github, Gitlab, or a similar web service, and create an empty repository called pkgname (you should use a different name, please follow the rules below) on that service. Then clone that repository to have a local empty directory on your computer, called pkgname, that is linked to this remote repository. Please see our wiki for a step-by-step walk-though of this method, illustrated with screenshots.
    • New project in RStudio first, then connect to GitHub/GitLab: An alternative approach is to create a local, empty, directory called pkgname on your computer (e.g. in your Desktop or Downloads folder), and initialize it with Git (git init), then create a GitHub/GitLab repository and connect your local project to the remote repository.
  • Whichever of those two methods that you choose, you continue by staging, commiting and pushing every future change in the repository with Git.
  • Your pkgname must follow some rules for everything to work, it must:
    • … contain only ASCII letters, numbers, and ‘.’
    • … have at least two characters
    • … start with a letter (not a number)
    • … not end with ‘.’

1. rrtools::use_compendium("pkgname")

  • if you started with a new project on GitHub first, run rrtools::use_compendium(), if you started with a new project in RStudio first, run rrtools::use_compendium("pkgname")
  • this uses usethis::create_package() to create a basic R package in the pkgname directory, and then, if you’re using RStudio, opens the project. If you’re not using RStudio, it sets the working directory to the pkgname directory.
  • we need to:
    • edit the DESCRIPTION file (located in your pkgname directory) to include accurate metadata, e.g. your ORCID and email address
    • periodically update the Imports: section of the DESCRIPTION file with the names of packages used in the code we write in the qmd document(s) by running rrtools::add_dependencies_to_description()

2. usethis::use_mit_license(copyright_holder = "My Name")

  • this adds a reference to the MIT license in the DESCRIPTION file and generates a LICENSE file listing the name provided as the copyright holder
  • to use a different license, replace this line with any of the licenses mentioned here: ?usethis::use_mit_license()

3. rrtools::use_readme_qmd()

  • this generates README.qmd and renders it to README.md, ready to display on GitHub. It contains:
    • a template citation to show others how to cite your project. Edit this to include the correct title and DOI.
    • license information for the text, figures, code and data in your compendium
  • this also adds two other markdown files: a code of conduct for users CONDUCT.md, and basic instructions for people who want to contribute to your project CONTRIBUTING.md, including for first-timers to git and GitHub.
  • this adds a .binder/Dockerfile that makes Binder work, if your compendium is hosted online. Currently configured for GitHub, but easily adapted for elsewhere (e.g. Zenodo, Figshare, Dataverse, etc.)
  • render this document after each change to refresh README.md, which is the file that GitHub displays on the repository home page

4. rrtools::use_analysis()

  • this function has three location = options: top_level to create a top-level analysis/ directory, inst to create an inst/ directory (so that all the sub-directories are available after the package is installed), and vignettes to create a vignettes/ directory (and automatically update the DESCRIPTION). The default is a top-level analysis/.
  • for each option, the contents of the sub-directories are the same, with the following (using the default analysis/ for example):
analysis/
|
├── paper/
│   ├── paper.qmd       # this is the main document to edit
│   └── references.bib  # this contains the reference list information

├── figures/            # location of the figures produced by the qmd
|
├── data/
│   ├── raw_data/       # data obtained from elsewhere
│   └── derived_data/   # data generated during the analysis
|
└── templates
    ├── journal-of-archaeological-science.csl
    |                   # this sets the style of citations & reference list
    ├── template.docx   # used to style the output of the paper.qmd
    └── template.Rmd
  • the paper.qmd is ready to write in and render with Quarto. It includes:
    • a YAML header that identifies the references.bib file and the supplied csl file (to style the reference list)
    • a colophon that adds some git commit details to the end of the document. This means that the output file (HTML/PDF/Word) is always traceable to a specific state of the code.
  • the references.bib file has just one item to demonstrate the format. It is ready to insert more reference details.
  • you can replace the supplied csl file with a different citation style from https://github.com/citation-style-language/
  • we recommend using the RStudio 2022.07 or higher to efficiently insert citations from your Zotero library while writing in an qmd file (see here for detailed setup and use information to connect your RStudio to your Zotero)
  • remember that the Imports: field in the DESCRIPTION file must include the names of all packages used in analysis documents (e.g. paper.qmd). We have a helper function rrtools::add_dependencies_to_description() that will scan the qmd file, identify libraries used in there, and add them to the DESCRIPTION file.
  • this function has an data_in_git = argument, which is TRUE by default. If set to FALSE you will exclude files in the data/ directory from being tracked by git and prevent them from appearing on GitHub. You should set data_in_git = FALSE if your data files are large (>100 mb is the limit for GitHub) or you do not want to make the data files publicly accessible on GitHub.
    • To load your custom code in the paper.qmd, you have a few options. You can write all your R code in chunks in the qmd, that’s the simplest method. Or you can write R code in script files in /R, and include devtools::load_all(".") at the top of your paper.qmd. Or you can write functions in /R and use library(pkgname) at the top of your paper.qmd, or omit library and preface each function call with pkgname::. Up to you to choose whatever seems most natural to you.

5. rrtools::use_dockerfile()

  • this creates a basic Dockerfile using rocker/verse as the base image
  • this also creates creates a minimal .yml configuration file to activate continuous integration using GitHub Actions. This will attempt to render your qmd document, in a Docker container specified by your Dockerfile, each time you push to GitHub. You can view the results of each attempt at the 'actions' page for your compendium on github.com, e.g. https://github.com/benmarwick/rrtools/actions
  • the version of R in your rocker container will match the version used when you run this function (e.g., rocker/verse:3.5.0)
  • rocker/verse includes R, the tidyverse, RStudio, pandoc and LaTeX, so compendium build times are very fast
  • we need to:
    • edit the Dockerfile to add linux dependencies (for R packages that require additional libraries outside of R). You can find out what these are by browsing the DESCRIPTION files of the other packages you’re using, and looking in the SystemRequirements field for each package. If you are getting build errors on GitHub Actions, check the logs. Often, the error messages will include the names of missing libraries.
    • modify which qmd files are rendered when the container is made
    • have a public GitHub repo to use the Dockerfile that this function generates. It is possible to keep the repository private and run a local Docker container with minor modifications to the Dockerfile that this function generates.

6. renv::init()

  • this initates tracking of the packages you use in your project using renv. renv will discover the R packages used in your project, and install those packages into a private project library
  • We can use renv::snapshot() to save the state of our project library from time to time, or at the end when we are ready to share. The project state will be saved into a file called renv.lock.
  • Our collaborators can run renv::restore() to install exactly those packages into their own library.
  • Don't skip this step because our Binder and Dockerfile use the renv.lock file to install the packages they need to run your code. So renv is an important component of making a compendium reproducible.

You should be able to follow these steps to get a new research compendium repository ready to write in just a few minutes.

References and related reading

Kitzes, J., Turek, D., & Deniz, F. (Eds.). (2017). The Practice of Reproducible Research: Case Studies and Lessons from the Data-Intensive Sciences. Oakland, CA: University of California Press. https://www.practicereproducibleresearch.org

Marwick, B. (2017). Computational reproducibility in archaeological research: Basic principles and a case study of their implementation. Journal of Archaeological Method and Theory, 24(2), 424-450. https://doi.org/10.1007/s10816-015-9272-9

Marwick, B., Boettiger, C., & Mullen, L. (2018). Packaging data analytical work reproducibly using R (and friends). The American Statistician 72(1), 80-88. https://doi.org/10.1080/00031305.2017.1375986

Piccolo, S. R. and M. B. Frampton (2016). “Tools and techniques for computational reproducibility.” GigaScience 5(1): 30. https://gigascience.biomedcentral.com/articles/10.1186/s13742-016-0135-4

rOpenSci community (2017b). rrrpkg: Use of an R package to facilitate reproducible research. Online at https://github.com/ropensci/rrrpkg

Schmidt, S.C. and Marwick, B., 2020. Tool-Driven Revolutions in Archaeological Science. Journal of Computer Applications in Archaeology, 3(1), pp.18–32. DOI: http://doi.org/10.5334/jcaa.29

Stodden, V. & Miguez, S., (2014). Best Practices for Computational Science: Software Infrastructure and Environments for Reproducible and Extensible Research. Journal of Open Research Software. 2(1), p.e21. DOI: http://doi.org/10.5334/jors.ay

Wickham, H. (2017) Research compendia. Note prepared for the 2017 rOpenSci Unconf. https://docs.google.com/document/d/1LzZKS44y4OEJa4Azg5reGToNAZL0e0HSUwxamNY7E-Y/edit#

Wilson G, Bryan J, Cranston K, Kitzes J, Nederbragt L, et al. (2017). Good enough practices in scientific computing. PLOS Computational Biology 13(6): e1005510. https://doi.org/10.1371/journal.pcbi.1005510

Contributing

If you would like to contribute to this project, please start by reading uur Guide to Contributing. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Acknowledgements

This project was developed during the 2017 Summer School on Reproducible Research in Landscape Archaeology at the Freie Universität Berlin (17-21 July), funded and jointly organized by Exc264 Topoi, CRC1266, and ISAAKiel. Special thanks to Sophie C. Schmidt for help. The convenience functions in this package are inspired by similar functions in the usethis package.

rrtools's People

Contributors

adamhsparks avatar annakrystalli avatar benmarwick avatar dakni avatar eliocamp avatar flukeandfeather avatar jbelmiro avatar nevrome avatar pkq avatar rekyt avatar rsbraun avatar sahirbhatnagar avatar sbfnk avatar scschmidt avatar softloud avatar wolass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rrtools's Issues

allegedly missing documentation entries: use_analysis

We get this weird warning in the R package check.

Status: 1 WARNING
checking for missing documentation entries ... WARNING
Undocumented code objects:
  ‘use_analysis’
All user-level objects in a package should have documentation entries.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.

use_analysis() is of course documented. There's a stackoverflow thread that discusses a similar problem. Maybe this could be fixed by changing the function name, but I hope for a more elegant solution.

@benmarwick I'm pretty sure that we already discussed about this some months ago. But maybe it's good to have an open bug report to keep this in mind. It's not an important issue, but mildly unsatisfying.

mixed case GH repo name makes Travis build fail

Uppercase characters in the global - REPO=$DOCKER_SER/REPO from line 5 of .travis.yml cause the build to fail with error:

invalid argument "mrecos/DistRegLMERR" for t: Error parsing reference: "mrecos/DistRegLMERR" is not a valid repository/tag: repository name must be lowercase

https://travis-ci.org/mrecos/DistRegLMERR/builds/274845050#L498

Manually changing it to lowercase allowed the build to proceed with no errors. I believe the repo name is originated here:

rrtools/R/git.R

Line 133 in 3f2d5cf

github_dummy <- list(username = "<USERNAME>", repo = "<REPO>", fullname = "<USERNAME>/<REPO>")

adding a tolower() in there somewhere could resolve the issue. Additionally, I tested to see if a lowercase repo name had any negative effect on the build where it is also used in line 25 of travis.yml. The travis build passed in both cases.

ERROR: installing package DESCRIPTION failed for package 'rrtools'

devtools::install_github("benmarwick/rrtools")
Downloading GitHub repo benmarwick/rrtools@master
from URL https://api.github.com/repos/benmarwick/rrtools/zipball/master
Installing rrtools
"C:/PROGRA1/R/R-341.2/bin/x64/R" --no-site-file --no-environ
--no-save --no-restore --quiet CMD INSTALL
"C:/Users/Jinn-Yuh/AppData/Local/Temp/RtmpwZgVAC/devtools2fb0eca7ba1/benmarwick-rrtools-45c4a9b"
--library="D:/Dropbox/Stat/R/Library" --install-tests

  • installing source package 'rrtools' ...
    Error in parse(con, encoding = "UTF-8") :
    invalid multibyte character in parser at line 4
    ERROR: installing package DESCRIPTION failed for package 'rrtools'
  • removing 'D:/Dropbox/Stat/R/Library/rrtools'
    Installation failed: Command failed (1)

rrtools::use_analysis(location = "vignettes") function fails to set up compendiumn

Expected behavior:

  • The following code would make a vignettes/analysis/ directory with a paper.Rmd file waiting for use:
devtools::install_github("benmarwick/rrtools")
rrtools::use_compendium("rrtoolsTEST")
rrtools::use_analysis(location = "vignettes")

Actual behavior:

  • It fails in the middle of the process with some elements missing
rrtools::use_analysis(location = "vignettes")
✔ Adding bookdown to Imports
✔ Creating 'vignettes' directory and contents
✔ Creating 'vignettes'
✔ Creating 'vignettes/paper'
✔ Creating 'vignettes/figures'
✔ Creating 'vignettes/templates'
✔ Creating 'vignettes/data'
✔ Creating 'vignettes/data/raw_data'
✔ Creating 'vignettes/data/derived_data'
✔ Creating 'references.bib' from template.
Error in usethis::ui_done("Adding ", paths, " to ", file.path(directory,  : 
  unused arguments (" to ", file.path(directory, ".gitignore"))

It seems like a simple fix to update line 210 in R/infrastructure-git.R:

usethis::ui_done("Adding ", paths, " to ", file.path(directory, ".gitignore"))

First git push in rrtools::use_github seems to be broken

In a new repository with git enabled:

> rrtools::use_github(auth_token = "1234", private = FALSE)
✔ Git is already initialized
✔ Checking title and description
✔   Title: What the Package Does (One Line, Title Case)
✔   Description: What the package does (one paragraph)
Are title and description ok?
1: Yup
2: No way
3: Uhhhh... Maybe?

Selection: 1
* Creating GitHub repository
✔ Adding GitHub remote
✔ Adding GitHub links to DESCRIPTION
* Pushing to GitHub and setting remote tracking branch
Error in git2r::push(r, "origin", "refs/heads/master", credentials = credentials) : 
  Error in 'git2r_push': error authenticating: 

The problem seems to be how git2r::push() acquires ssh credentials. Maybe it's just a user error or a problem with my system. But my ssh-agent ist running and I see no problem here.

> sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 os       Manjaro Linux               
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Berlin               
 date     2018-11-02                  

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       lib source                          
 assertthat    0.2.0   2017-04-11 [1] CRAN (R 3.5.1)                  
 backports     1.1.2   2017-12-13 [1] CRAN (R 3.5.1)                  
 cli           1.0.1   2018-09-25 [1] CRAN (R 3.5.1)                  
 clisymbols    1.2.0   2017-05-21 [1] CRAN (R 3.5.1)                  
 crayon        1.3.4   2017-09-16 [1] CRAN (R 3.5.1)                  
 curl          3.2     2018-03-28 [1] CRAN (R 3.5.1)                  
 digest        0.6.18  2018-10-10 [1] CRAN (R 3.5.1)                  
 evaluate      0.12    2018-10-09 [1] CRAN (R 3.5.1)                  
 fs            1.2.6   2018-08-23 [1] CRAN (R 3.5.1)                  
 git2r         0.23.0  2018-07-17 [1] CRAN (R 3.5.1)                  
 glue          1.3.0   2018-07-17 [1] CRAN (R 3.5.1)                  
 htmltools     0.3.6   2017-04-28 [1] CRAN (R 3.5.1)                  
 knitr         1.20    2018-02-20 [1] CRAN (R 3.5.1)                  
 Rcpp          0.12.19 2018-10-01 [1] CRAN (R 3.5.1)                  
 rmarkdown     1.10    2018-06-11 [1] CRAN (R 3.5.1)                  
 rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.5.1)                  
 rrtools     * 0.1.0   2018-11-02 [1] Github (nevrome/rrtools@06d2c2f)
 rstudioapi    0.8     2018-10-02 [1] CRAN (R 3.5.1)                  
 sessioninfo   1.1.0   2018-09-25 [1] CRAN (R 3.5.1)                  
 usethis       1.4.0   2018-08-14 [1] CRAN (R 3.5.1)                  
 withr         2.1.2   2018-03-15 [1] CRAN (R 3.5.1)                  
 yaml          2.2.0   2018-07-25 [1] CRAN (R 3.5.1)                  

[1] /home/clemens/R/x86_64-pc-linux-gnu-library/3.5
[2] /usr/lib/R/library

replace devtools with usethis

Many of the helper functions in devtools now have more user-friendly implementations in usethis (more chatty feedback in the console, colour in the messages, etc.). Should we shift to usethis::create to support rrtools::use_compendium("pkgname") and usethis::use_github instead of devtools::use_github?

wrong figure location -- use_analysis

Hi Ben!

when I use use_analysis() the analysis folder is created, including the sudirectory figures. When knitting the plot graphics are intended to be placed there. However, they get the name figures$CHUNKNAME.$FORMAT and are placed in the paper directory.

The manual workaround to achieve the intended behavior is to change the fig.path in the setup chunk of the Rmd to fig.path = "../figures/".

I searched through the rrtools functions in order to update the code/resolve this "bug" but I don't find the location where the setup chunk is created

Create GitHub Repo did not worked on Mac

While trying out the workflow during lunchtime today on @nmueller18 mac, Creating GitHub repository resulted in

Fehler in stop(github_error(req)) : Not Found (404)

We had to create the repo by hand and had to use git remote add stattinstead ofgit remote set-url`.

Could not find a pull request solving that issue, so it might remain a problem. From my Arch machine, everything went well regarding this.

`rrtools` currently lacks package management, reducing reproducibility

In brief:

  • Problem: rrtools with Dockerfile is currently reproducible, conditional upon the time one builds the Docker image that produces paper.html (or one's trust in a custom Docker container published to DockerHub (or a similar registry)).
  • (Partial) Solution: packrat (and perhaps eventually rstudio/renv?) can record the exact version of all packages and Dockerfile can reproduce that state.

Details:

A Dockerfile contains enough information to create an environment, but not enough information to reproduce an environment. Consider a Dockerfile that contains the command “install.packages(‘dplyr’)”. Following this instruction in August 2017 and again in December 2017 will result in two different Docker containers, since the current version changed. -RStudio and Docker

[Question] How do I access an object stored in the package from the paper.RMD file?

Hi I figured that the files are nicely saving in the directories (all scripts in R folder and figures where they are supposed to!) Thats great.

So next thing that occured to me is that I do not need to call every script per source() function in the paper.Rmd file. I only need to call the package here! That's great too!

My question is now can I call a variable that was created in the R/analysis.R script to be evaluated in the paper.Rnw file?

To illustrate R/analysis.R:

df <- data.frame(x=1,y=2)

analysis/paper/paper.Rmd

library(CREATED_PACKAGE)
paste0("There were", df$x, " events") 

The above code produces an error

I'm sure that I am missing an info how to properly build a package... any help here?

I really love this package and it has been super-helpful!!!!1
Please do not stop developing it!!!

Organize README around concepts rather than functions

Currently, the how to section in the README is organized by rrtools function. However, there are several places where the appropriate function depends on the user's choice (e.g., which license to use), or where there are steps the user has to complete before running the rrtools function (e.g., when setting up version control).

Does it make sense to instead organize this section around the concept each step represents (e.g., create the package, choose a license, use version control), listing any prerequisite steps, and then the function? One potential benefit is that this would help reinforce the key components of rr, particularly for people who are less familiar with them. The downside, of course, is that it requires a bit more effort to locate the appropriate function. Organizing things conceptually seems useful to me, but perhaps the current approach was intentional?

Happy to make a first attempt at this, if others are amenable.

Error: Could not find package root.

Getting this error when I use:

rrtools::use_analysis()

setting value
version R version 3.4.1 (2017-06-30)
system x86_64, mingw32
ui RStudio (1.0.153)
language (EN)
collate English_United States.1252
tz Africa/Johannesburg
date 2017-07-28

Packages ------------------------------------------------------------------------------
package * version date source
backports 1.1.0 2017-05-22 CRAN (R 3.4.0)
base * 3.4.1 2017-06-30 local
colorspace 1.3-2 2016-12-14 CRAN (R 3.4.0)
compiler 3.4.1 2017-06-30 local
curl 2.8.1 2017-07-21 CRAN (R 3.4.1)
datasets * 3.4.1 2017-06-30 local
devtools * 1.13.2 2017-06-02 CRAN (R 3.4.0)
digest 0.6.12 2017-01-27 CRAN (R 3.4.0)
evaluate 0.10.1 2017-06-24 CRAN (R 3.4.0)
ggplot2 2.2.1 2016-12-30 CRAN (R 3.4.0)
git2r 0.19.0 2017-07-19 CRAN (R 3.4.1)
graphics * 3.4.1 2017-06-30 local
grDevices * 3.4.1 2017-06-30 local
grid 3.4.1 2017-06-30 local
gtable 0.2.0 2016-02-26 CRAN (R 3.4.0)
htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0)
httr 1.2.1 2016-07-03 CRAN (R 3.4.0)
knitr 1.16 2017-05-18 CRAN (R 3.4.0)
lazyeval 0.2.0 2016-06-12 CRAN (R 3.4.0)
magrittr 1.5 2014-11-22 CRAN (R 3.4.0)
memoise 1.1.0 2017-04-21 CRAN (R 3.4.0)
methods * 3.4.1 2017-06-30 local
munsell 0.4.3 2016-02-13 CRAN (R 3.4.0)
plyr 1.8.4 2016-06-08 CRAN (R 3.4.0)
R6 2.2.2 2017-06-17 CRAN (R 3.4.0)
Rcpp 0.12.12 2017-07-15 CRAN (R 3.4.1)
rlang 0.1.1 2017-05-18 CRAN (R 3.4.0)
rmarkdown 1.6 2017-06-15 CRAN (R 3.4.0)
rprojroot 1.2 2017-01-16 CRAN (R 3.4.0)
rrtools 0.1.0 2017-07-28 Github (b9cf7f1)
rstudioapi 0.6.0.9000 2017-07-28 Github (rstudio/rstudioapi@41dfa7f)
scales 0.4.1 2016-11-09 CRAN (R 3.4.0)
stats * 3.4.1 2017-06-30 local
stringi 1.1.5 2017-04-07 CRAN (R 3.4.0)
stringr 1.2.0 2017-02-18 CRAN (R 3.4.0)
tibble 1.3.3 2017-05-29 Github (tidyverse/tibble@b2275d5)
tools 3.4.1 2017-06-30 local
utils * 3.4.1 2017-06-30 local
whisker 0.3-2 2013-04-28 CRAN (R 3.4.0)
withr 1.0.2 2016-06-20 CRAN (R 3.4.0)

Package installation issue on Windows

I get an error when trying to install this specific repo (I tried for wordcountaddin and it works).

> devtools::install_github("benmarwick/rrtools")
Downloading GitHub repo benmarwick/rrtools@master
√  checking for file 'C:\Users\Matthew\AppData\Local\Temp\RtmpSiOQXr\remotes449cbac15fc\benmarwick-rrtools-d52ebf1/DESCRIPTION' (414ms)
-  preparing 'rrtools': (427ms)
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
   Removed empty directory 'rrtools/analysis'
-  building 'rrtools_0.1.0.tar.gz'
   
Installing package into ‘C:/Users/Matthew/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package 'rrtools' ...
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'rrtools'
    finding HTML links ... done
    add_dependencies_to_description         html  
    as.package                              html  
    check_dep_version                       html  
    create_compendium                       html  
    github_pat                              html  
    is.package                              html  
    package_file                            html  
    parse_deps                              html  
    use_analysis                            html  
    use_build_ignore                        html  
    use_circleci                            html  
    use_compendium                          html  
    use_dockerfile                          html  
    use_git                                 html  
    use_git_hook                            html  
    use_git_quietly                         html  
    use_github                              html  
    use_github_links                        html  
    use_readme_rmd                          html  
    use_travis                              html  
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'rrtools':
 .onAttach failed in attachNamespace() for 'rrtools', details:
  call: get(name, envir = asNamespace(pkg), inherits = FALSE)
  error: object 'field' not found
Error: loading failed
Execution halted
*** arch - x64
Error: package or namespace load failed for 'rrtools':
 .onAttach failed in attachNamespace() for 'rrtools', details:
  call: get(name, envir = asNamespace(pkg), inherits = FALSE)
  error: object 'field' not found
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/Users/Matthew/Documents/R/win-library/3.5/rrtools'
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package ‘C:/Users/Matthew/AppData/Local/Temp/RtmpSiOQXr/file449c786c3c93/rrtools_0.1.0.tar.gz’ had non-zero exit status

Here's my environment:

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C                    LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1         rstudioapi_0.10    magrittr_1.5       usethis_1.4.0.9000 devtools_2.0.1    
 [6] pkgload_1.0.2      R6_2.4.0           rlang_0.3.3        tools_3.5.2        pkgbuild_1.0.3    
[11] sessioninfo_1.1.1  cli_1.1.0          withr_2.1.2        remotes_2.0.2      assertthat_0.2.1  
[16] digest_0.6.18      rprojroot_1.3-2    crayon_1.3.4       processx_3.3.0     callr_3.2.0       
[21] fs_1.2.7           ps_1.3.0           curl_3.3           testthat_2.0.1     memoise_1.1.0.9000
[26] glue_1.3.1         compiler_3.5.2     desc_1.2.0         backports_1.1.3    prettyunits_1.0.2 

Generate README references using .bib

Should the references cited in the README get auto-generated from a references.bib file? It seems odd to advocate for that approach and then not use it, but perhaps I'm missing something?

I think this would require moving the Contributing section ahead of the references, unless there's a way to generate the references somewhere other than the end of the file?

Add unit tests

We should have unit tests for the core functions in this package and their variants.

This will be a bit different from usual tests because they output files and directories, and some do things on other services that we may not be able to do with Travis.

use_circleci

Looks like this can do CI on private GitHub repos for free, unlike Travis, so that is an option we want here too.

Thesis and book templates

Perhaps https://github.com/ismayc/thesisdown for a thesis and just https://github.com/rstudio/bookdown-demo for a book?

Do we simply have use_analysis(structure = c("paper", "thesis", "book")) and then, depending on the choice, create either:

Does this seem like the right way to provide these options?

Docum. is outdated: update README: usethis::use_mit_license()

This is only a tiny problem, too small for a pull request.

The documentation/README.md seems to be outdated here.

Please consider updating the README.md file:

usethis::use_mit_license(copyright_holder = "my name")

Error in usethis::use_mit_license(copyright_holder = "my name") : 
  unused argument (copyright_holder = "my name")

With

usethis::use_mit_license(name = "My Name")

Result:

✔ Setting License field in DESCRIPTION to 'MIT + file LICENSE'
✔ Writing 'LICENSE.md'
✔ Adding '^LICENSE\.md$' to '.Rbuildignore'
✔ Writing 'LICENSE'

I also think step 3 (devtools::use_github(...)) should be marked as optional, maybe in a subtle way. Uploading the repo to github early might pollute the github account with incomplete repositories and package stubs. This is just my personal opinion.

Also, a bulletpoint could be added (to step 3) that all subtasks of step 1 must be completed otherwise the uploader will croak.

topic 5 contains a typo:

"vingettes" to create a "vingettes/"

(the rrtools::use_analysis( location = "vignettes") call works properly, though)

Add a one-liner meta-function

I had some feedback from @clanfear that it would be useful to have a single function that combines most of the steps. Like a meta-function. We could have 2-3 main options, e.g.

  • a very basic, lightweight compendium suitable for student assignments,
  • a more elaborate one, and then
  • the kitchen sink with CI and docker for example.

I think this meta-function could be useful in workshop lessons where we don't have time to review every step in detail, but where we want to give a quick taste of how to do reproducibile research easily.

What do you think?

Dependencies

Does rrtools really need the complete tidyverse in Imports?

rOpenSci review and CRAN release

Although installing from GitHub using devtools works fine, it would be mildly more convenient, and more familiar to newer R users, to install it the standard way from CRAN. This package seems fairly mature, is a CRAN release planned?

Scanning through issues I can find one that would hold up a CRAN release:

  • #70: The use of unexported/internal functions called via ::: is not allowed by CRAN

Any others?

[enhancement] Use templates for standardized reporting guidelines

Many scientific reports have specific structures.

Original articles, RCTs, literature reviews and case reports are distinctly different papers.

Whenever one would start writing - it is necessary to make a structure of a specific type.
Moreover, there are multiple guidelines how to efficiently (and by standardized matter) write a specific report.

So let's say I would like to write a Case report in a medical journal.
The http://www.equator-network.org/ page provides the guidelines on how to write various scientific manuscripts and which information needs to be in these reports. They also recommend the best set of guidelines for the job.

We find that for the case reports the CARE guidelines are recommended.
http://www.equator-network.org/reporting-guidelines/care/
Therefore we would like to write a case report using these guidelines. They provide a set of tips and checklists while writing. But finding them and using them could be easier.

I have just started writing a package that is meant to be an extension to the rrtools by providing these guidelines as templates 'paper.Rmd' file.

There is, of course, a ton of work to be done to make all of these guidelines available.

Please let me know what you think - if this is useful, and if you see a method to simplify the template creation process by maybe scraping the equator webpage?

the package (with only one template right now) can be found here: https://github.com/wolass/reportingGuidelines

The only way to use it right now is to start a repository using rrtools and use_analysis(). After that the function reportingGuidelines::useGuideline("case") will replace the paper.Rmd file with a CARE_statement template.

The template has the tips and checklist items included in it - to provide a thorough reference while writing the report. So no need to lookup the EQUATOR webpage, download the templates yourself and get back to R. It is all in one place.

codemeta json for compendia

I heard recently that rOpenSci will soon be asking for codemeta.json metadata for submissions to their family of packages. They may be able to simplify this with a new function usethis::use_codemeta() which would use https://github.com/ropensci/codemetar. This metadata format is widely accepted by many trustworthy repositories.

We might want to consider this too. Perhaps we could auto-generate this json file during rrtools::use_analysis() or some other point after the DESCRIPTION is well-populated? And then prompt the user to update it later maybe?

use_analysis function and pkg path

I ran into this issue because I am testing the "RStudio-free" Version of rrtools.

When calling

rrtools::use_analysis()

I receive this output

* Adding bookdown to Imports
Next: 
 * Write your article/paper/thesis in Rmd file(s) in analysis/paper/
 * Add the citation style libray file (csl) to replace the default in analysis/paper/
 * Add reference details to the references.bib in analysis/paper/
 * For adding captions & cross-referenceing in an Rmd, see https://bookdown.org/yihui/bookdown/ 
 * For adding citations & reference lists in an Rmd, see http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html 

Besides all files are created as expected. Nice.

However, when calling

rrtools::use_analysis(pkg = "MyPackage")

I receive this error

* Adding bookdown to Imports
Error in file.copy(from = list.files(system.file("templates/word_templates/",  : 
  more 'from' files than 'to' files

Why is it not possible to state the pkgpath explicitly? My current attempts failed (I suspect a problem with

Besides the "bug", I think this is a somewhat important issue because IMO it is not good to rely too much on the automagic of RStudio...in this case its automatic changing of the working directory when creating a package.

My workaround looks like this (ugly, I know...):

use_analysis <- function(pkg = ".", template = 'paper.Rmd') {
  if (pkg != ".") {
    setwd(pkg)
    ugly <- TRUE
    pkg <- "."
  }

...

if (ugly == TRUE) {
    setwd("..")
}
  
invisible(TRUE)
}

hadley/requirements

@dakni and I wrote the add_dependencies_to_description() function to search the code in the repository for package dependencies. I've just seen that @hadley started to work on a package to do exactly this. I expect it to be or at least to become more sophisticated than our function.

This issue is supposed to be a reminder that we could replace and improve our function in the future relying on hadley/requirements.

use GitLab

Are there any plans to enable users to use GitLab and its CI service instead of GitHub and Travis/CircleCI? That would be fantastic as one could use (unlimited) private repositories.

If you don't plan on extending the package, do you have suggestions on how one could integrate GitLab plus CI into the rrtools workflow? Thanks!

The use of unexported/internal functions called via ::: is not allowed by CRAN

We get a new NOTE in the check results:

* checking dependencies in R code ... NOTE
Unexported objects imported by ':::' calls:
  ‘usethis:::done’ ‘usethis:::field’ ‘usethis:::git_uncommitted’
  ‘usethis:::todo’ ‘usethis:::value’
  See the note in ?`:::` about the use of this operator.

We have four options to deal with this:

  1. Ignore it. A CRAN release would be difficult though.
  2. Contact the usethis package authors and ask them to export these functions.
  3. Copy the function source code (and cite the author).
  4. This nasty workaround: https://stat.ethz.ch/pipermail/r-devel/2013-August/067210.html

README.Rmd won't allow pkgdown site to build

If using pkgdown to build a site, the process fails with:

Updating README.md
Error in (function (variant = "markdown_strict", preserve_yaml = FALSE,  : 
  unused argument (html_preview = FALSE)

Currently the YAML reads:

---
output:
  md_document:
    variant: markdown_github
---

changing the YAML to instead be:

output: github_document

builds the _pkgdown_site

Template path incorrect

In the paper.Rmd file the path to the template file is wrong.

it should be ../templates/template.docx

custom knit to update DESCRIPTION Imports during knitting

In e235c44 I have tried to over-ride the knit button to trigger a function that scans the Rmd for library() etc. calls, and update the DESCRIPTION Imports with the names of all the packages used in the Rmd. I often get tripped up because I forget to add those, so I'm looking for a way to automate this.

I have added a line to the YAML in paper.Rmd, and a new function knit_and_update_desc_imports to try and do this. It works, but only if we import packrat, which I don't want to do.

The problem is that I cannot exactly duplicate the key function for scanning the Rmd, packrat:::fileDependencies. I have tried to copy in all the relevant code from packrat, to avoid the dependency (because that gives warnings with devtools). But still I cannot make my local fileDependencies work, only packrat:::fileDependencies works.

I would like your feedback on (1) if this is a good idea and (2) how to make the local fileDependencies work without using packrat.

I have also directly copied in a lot of code from devtools so we don't have to use ::: at all anymore. That gets rid of a bunch of warnings.

Allow symlinks in `use_compendium()`

When initiating a new compendium with:

rrtools::use_compendium("~/path/to/new/compendium")

where ~/path/to/new is a symlink to /some/other/path, rrtools throws an error:

> rrtools::use_compendium("~/path/to/new/compendium")
Error: '/home/nfs/user.name/path/to/new' is not a directory.

However, replacing symlink with full path works:

rrtools::use_compendium("/some/other/path/compendium")

Page breaking in the paper.Rmd file

There are requirements by some of the journals to provide tables on separate pages. Is it possible to do in the Rmarkdown file?

I have noticed people using Heading 5 (#####) with the paragraph style performing a page break but I find it a bit hacky.

Is there a better solution to this issue? maybe also one that does not require shady-Haskell-recompilation of the pandoc filters??

Track changes made to the manuscript during peer review.

After submitting my first paper in DOCX generated strictly with the rrtools workflow I am now in the first revision.

The problem that occured is that whenever I am introducing changes to the manuscript these are only visible in the .RMD file (and this is perfectly fine if reviewers would use github).

Do you have any ideas how to introduce "changes tracking" in the generated manuscripts - this is often required by journals and generally a good practice to always state what has been modified from the original file.

I suppose a simple color change would be sufficient.

Is there an elegant (or at least a hackable) solution to this?

Uppercase characters are not allowed in package names

create_compendium() and use_compendium() refuse to make a package with uppercase characters in the name:

> rrtools::use_compendium("LongWindedScientificAnalysis")
Error: 'LongWindedScientificAnalysis' is not a valid package name. It should:
* Contain only ASCII letters, numbers, and '.'
* Have at least two characters
* Start with a letter
* Not end with '.'
* Not contain any upper case characters

This was added f2e3b43, to ensure compatibility with travis. But I'd make the case for allowing uppercase characters:

  • R, CRAN, and GitHub all support mixed case. Only travis is a problem, but most? users won't use travis.
  • Research compendiums are more likely to have long, multi-word names than conventional packages. These are hard to parse in all-lowercase (longwindedscientificanalysis).
  • Common word separators like _ and -—which would solve the above problem—aren't allowed in R package names. . is, but most modern R style guides recommend against using it as a word separator.

A solution would be to throw a warning about the travis issue when creating a compendium with uppercase characters, rather than an error. The hard check could be moved to use_travis().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.