Giter Club home page Giter Club logo

rnotebook's Introduction

rnotebook: R Notebook based on JSON and R Markdown

Build Status

Traditional dynamic documents based on knitr are normally compiled to output documents. The separation between the source document and output document has its pros and cons. The source document is often cleaner than the output document, and easier to maintain. But some people may prefer the output to be embedded right in the source document, so they only need to maintain one single document, in which they can see both the source and output.

This package tries to define a JSON-based format for dynamic documents in R. There is no formal definition for an "R Notebook", and we use this term here because what we did in this package is similar to IPython notebooks, which is also based on JSON.

The R Notebook in this package is a JSON file, which is basically a JavaScript object with meta information, code chunks, and text chunks. Here is an example (created from rnotebook::newnb()):

{
  "frontmatter": {
    "title": "An R Notebook",
    "author": "Yihui Xie",
    "date": "2014-12-26"
  },
  "body": [
    {
      "type": "text",
      "src": "A _sample_ paragraph.",
      "out": ""
    },
    {
      "type": "code",
      "src": {
        "options": "tidy = TRUE",
        "code": "1 + 1; x = dnorm(0)"
      },
      "out": ""
    },
    {
      "type": "text",
      "src": [
        "We know the density of N(0, 1)",
        "at 0 is `r x`."
      ],
      "out": ""
    }
  ]
}

The format should be clear if you are familiar with knitr documents and JSON. When compiling this document, the output is written into the out elements of the body cells instead of a new file. That is how the source and output are combined in one single file.

This package is just my proof of concept, and it may or may not be a worthwhile project in the future, given the popularity of R Markdown v2.

rnotebook's People

Contributors

yihui avatar

Watchers

 avatar  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.