MyNixOS website logo
Description

Jot Down Values for Later.

Reproducible work requires a record of where every statistic originated. When writing reports, some data is too big to load in the same environment and some statistics take a while to compute. This package offers a way to keep notes on statistics, simple functions, and small objects. Notepads can be locked to avoid accidental updates. Notepads keep track of who added the notes and when the notes were added. A simple text representation is used to allow for clear version histories.

jot

R-CMD-check

The goal of jot is to improve reproducability by allowing you to track statistics needed for an Rmd but are too big to open. Some statistics require summarizing large datasets or take a long time to calculate.

jot approaches this with the following organizing principles: 1. Notes should be lockable, so that tests don’t accidentally overwrite existing statistics. 2. We want to know when each statistic was last updated. 3. For collaborative projects, we want to know who last updated each statistic. 4. Records should play well with GitHub, which is done by representing notes as yaml.

Installation

You can install the development version of jot like so:

remotes::install_github('christopherkenny/jot')

Example

The normal workflow with jot is two staged, first is creating notes and second is reading them.

To create notes:

First, we make a notepad, giving it a location and a title.

library(jot)

path <- tempfile(fileext = '.yaml')

jot_new_pad(pad = path, title = 'example')

The contents of the new pad will look like:

title: example
locked: FALSE
home: the_path.yaml

By creating a new notepad, we set it to be the active notepad. The active notepad is represented as a path.

jot_active()
#> [1] "C:\\Users\\chris\\AppData\\Local\\Temp\\RtmpAFuA8J\\file2cfc4cc14957.yaml"

To write to the notepad can use jot():

jot(note = 3, name = 'estimate')

By default, it writes to the active notepad, which is now:

title: example
locked: no
home: the\path.yaml
estimate:
  last_update: 1659545779
  user: chris
  content: 3.0
  quoted: no
jot(note = 4, name = 'estimate')
#> Warning: `name` already exists and `overwrite` is "FALSE". No updates were made.

So, the notepad will still say:

title: example
locked: no
home: the\path.yaml
estimate:
  last_update: 1659545779
  user: chris
  content: 3.0
  quoted: no

We can fix that by explicitly overwriting.

jot(note = 4, name = 'estimate', overwrite = TRUE)

This gives us:

title: example
locked: no
home: the\path.yaml
estimate:
  last_update: 1659545993
  user: chris
  content: 4.0
  quoted: no

We can add other values as long as they have a different name:

jot(note = list(a = 1, b = 2, c = 3), name = 'list_abc', overwrite = TRUE)

We can even add fancier things like data.frames, but this should be limited to small things! The goal of jot is to store summaries and statistics, not all of your data.

jot(data.frame(col1 = 1, col2 = 2, col3 = 3), 'df')

Once we’re happy with the notes, we should lock the notepad.

jot_lock()

This sets the locked value to TRUE (and yes in the yaml).

title: example
locked: yes
home: the\path.yaml
estimate:
  last_update: 1659545993
  user: chris
  content: 4.0
  quoted: no
list_abc:
  last_update: 1659546469
  user: chris
  content:
    a: 1.0
    b: 2.0
    c: 3.0
  quoted: no

To read notes:

In the setup chunk for an Rmd, we add:

library(jot)
jot_activate(pad = path)

Here, we use the same temp path that we were writing to above, but generally this should be something within the project.

Now, we can read out values.

We can skim the note and report back everything:

jot_skim()
#> $estimate
#> [1] 4
#> 
#> $list_abc
#> $list_abc$a
#> [1] 1
#> 
#> $list_abc$b
#> [1] 2
#> 
#> $list_abc$c
#> [1] 3
#> 
#> 
#> $df
#>   col1 col2 col3
#> 1    1    2    3

Or, we can select a specific element that we’ve stored.

jot_read(name = 'estimate')
#> [1] 4

It returns the object of the same type as was inputted, so list_abc is a list:

jot_read(name = 'list_abc')
#> $a
#> [1] 1
#> 
#> $b
#> [1] 2
#> 
#> $c
#> [1] 3
Metadata

Version

0.0.4

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows