Experiment with changes in an R project

Inspired by the Ruby gem scientist - but instead of targeted at web apps, this project targets researchers/etc. that want to compare changes in their code in a rigorous fashion.

How is this different from X tool?

  • git/version control: scientist does not play any part in managing or dealing versions of your project. use git for that.
  • unit tests: tests are meant for making sure changes you make to your code don’t change outputs. scientist is a sort of opposite to unit tests in that it aims to tell you how changes in your code do change the outputs.
  • benchmarking/profiling: scientist isn’t purely a tool for comparing how fast your code runs, but it does include comparison of run times as a tool for decision making about what version to use

Use cases (click to expand)

Code block

You have some code. You want to make a change to the code, and you have a few different ideas about what you'd like to do. For example, you want to pre-allocate the size of the data.frame to see if that saves time. `scientist` can help you sort out changes by comparing how long each version takes, and visually diff results. Using `scientist` you can compare these two functions like: ```r a

Scripts

You have an R script, let's call it `code.R`. Just as above with the code example, you want to make a change to the script. Instead of using code blocks as input as above, you can use file names. (NOTE: file names not supported yet, see [issue #7](https://github.com/ropenscilabs/scientist/issues/7)) Using `scientist` you can compare these two scripts with: ```r b note: above code doesn't work yet

Packages

You have a package, let's call it `foobar`. You want to change a function in `foobar` called `stuff()`. You make a new version of that function called `stuff_new()`. (NOTE: functions not supported yet per se, see [issue #8](https://github.com/ropenscilabs/scientist/issues/8); although you can call functions just like code blocks) Using `scientist` you can compare these two functions with: ```r res note: above is pseudocode, as foobar is not a real package; though > you can try functions from a real package

Install

remotes::install_github("ropenscilabs/scientist")
library(scientist)

Meta

ropensci_footer