GithubHelp home page GithubHelp logo

jimhester / kumquat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kickstarter/kumquat

0.0 2.0 0.0 252 KB

Kumquat is a Rails Engine for rendering RMarkdown files.

License: MIT License

Ruby 89.28% JavaScript 1.96% CSS 1.67% HTML 7.09%

kumquat's Introduction

Kumquat

Kumquat is a reporting tool for rendering RMarkdown files inside Rails.

RMarkdown, or .Rmd files are Markdown files with code chunks of R in them.

You can use Kumquat to integerate R output into Rails, which is useful for using libaries like ggplot2 in email reporting tools.

Example

For example, consider a typical render call to a partial:

render '_a_knitr_report'

This partial is _a_knitr_report.Rmd, a regular RMarkdown file stored in your app:

A Test Report for Kumquat
========================================================

This is some code for Knitr, including [a link](https://www.kickstarter.com).

A list:

* One
* Another thing
* Last thing!

### More stuff.

Lorem Ipsum.

    ```{r, fig.width=10, fig.height=8, echo=FALSE, message=FALSE}
    library(ggplot2)
    qplot(data = data.frame( x = runif(100), y = runif(100) ), x = x, y = y)
    ```

Which yields the following output:

Kumquat Screenshot

Kumquat can be integrated anywhere inside Rails views where partials are called.

How it Works

Kumquat requires R to be installed on the machines running your application. The main action is then in Knit2HTML which shells out to Rscript and runs the necessary knitr package methods to compile HTML.

When you install Kumquat a template handler is registered to handle Rmd files.

Also, Email

A mail interceptor, KumquatReportInterceptor is also registered to attach images inline to Rmd reports marked with an X-KUMQUAT signature which you can add to a mail object accordingly:

    mail :to => @admin.email,
      :reply_to => "[email protected]",
      :subject => "Test Kumquat Report",
      'X-KUMQUAT' => true do |format|
        format.text { render layout: nil }
        format.html { render layout: nil }
    end

Setup & Development

Kumquat requires R to be installed, and the knitr packages to render RMarkdown files. The rest of the R dependencies are up to you, but need to be specified in the KNITR_LIBRARIES constant in the Knit2HTML class.

Chef Recipe

If you're curious about installing R using Chef, check out a suggested recipe on the wiki

Database Support

If you need to connect R to a database and provide credentials from your application, you can do so in an application initializer like so:

Kumquat.database_config(Configs[:redshift].merge({ database_connector: "RPostgres::Postgres()" }))

We are using Hadley Wickham's RPostgres library which can be installed in R accordingly:

install.packages("devtools")
devtools::install_github("RcppCore/Rcpp")
devtools::install_github("rstats-db/DBI")
devtools::install_github("rstats-db/RPostgres")

library(DBI)

Sending emails from a local development environment

If you'd like to deliver emails in your local environment, make sure your config.action_mailer.delivery_method is configured properly, and you have a way to send email locally (on OS X, run the command sudo postfix start).

Logging

You can view kumquat and email logs for debugging tail -f log/kumquat.log

kumquat's People

Contributors

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