Giter Club home page Giter Club logo

matahari's Introduction

matahari

CRAN status Travis-CI Build Status

Spy on Your R Session

A simple package for tidy logging of everything you type into the R console.

Installation

You can install matahari from CRAN with:

install.packages("matahari")

Or from GitHub with:

# install.packages("devtools")
devtools::install_github("jhudsl/matahari")

Getting Started

library(matahari)
library(tidyverse)
library(knitr)

# Start logging your commands
dance_start(value = TRUE)

4 + 4
"wow!"
mean(1:10)

# Pause logging
dance_stop()

# Look at your log as a tibble
dance_tbl()

## # A tibble: 6 x 6
##   expr       value             path      contents  selection dt                 
##   <list>     <list>            <list>    <list>    <list>    <dttm>             
## 1 <language> <S3: sessionInfo> <lgl [1]> <lgl [1]> <lgl [1]> 2018-06-23 15:26:06
## 2 <language> <int [1]>         <lgl [1]> <lgl [1]> <lgl [1]> 2018-06-23 15:26:06
## 3 <language> <dbl [1]>         <lgl [1]> <lgl [1]> <lgl [1]> 2018-06-23 15:26:07
## 4 <chr [1]>  <chr [1]>         <lgl [1]> <lgl [1]> <lgl [1]> 2018-06-23 15:26:08
## 5 <language> <dbl [1]>         <lgl [1]> <lgl [1]> <lgl [1]> 2018-06-23 15:26:08
## 6 <language> <S3: sessionInfo> <lgl [1]> <lgl [1]> <lgl [1]> 2018-06-23 15:26:09

# Do data science
dance_tbl() %>%
  slice(2:(n() - 1)) %>%
  select(expr, value) %>%
  mutate(class = map_chr(expr, class)) %>%
  kable()

## |expr                      |value |class     |
## |:-------------------------|:-----|:---------|
## |dance_start(value = TRUE) |1     |call      |
## |4 + 4                     |8     |call      |
## |wow!                      |wow!  |character |
## |mean(1:10)                |5.5   |call      |

Evaluating files

library(matahari)
library(tidyverse)
library(knitr)

code_file <- system.file("test", "sample_code.R", package = "matahari")

code_file %>%
  dance_recital() %>% 
  kable()
  
## |expr                |result   |error           |output   |warnings |messages |
## |:-------------------|:--------|:---------------|:--------|:--------|:--------|
## |4 + 4               |8        |NULL            |         |         |         |
## |wow!                |wow!     |NULL            |         |         |         |
## |mean(1:10)          |5.5      |NULL            |         |         |         |
## |stop("Error!")      |NULL     |Error!, .f(...) |NULL     |NULL     |NULL     |
## |warning("Warning!") |Warning! |NULL            |         |Warning! |         |
## |message("Hello?")   |NULL     |NULL            |         |         |Hello?   |
## |cat("Welcome!")     |NULL     |NULL            |Welcome! |         |         |

code_string <- "set.seed(42)\nx <- sample(1:10, 5)\nmedian(x)"

code_string %>%
  dance_recital() %>% 
  kable()

## |expr                 |result         |error |output |warnings |messages |
## |:--------------------|:--------------|:-----|:------|:--------|:--------|
## |set.seed(42)         |NULL           |NULL  |       |         |         |
## |x <- sample(1:10, 5) |10, 9, 3, 6, 4 |NULL  |       |         |         |
## |median(x)            |6              |NULL  |       |         |         |

matahari's People

Contributors

lucymcgowan avatar nischalshrestha avatar seankross avatar

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.