Git Product home page Git Product logo

rnvd3's Introduction

NOTE: Features of rNVD3 have now been incorporated into rCharts. rCharts supports several other JS charting libraries including NVD3, with a plotting interface familiar to R users. Development will cease on rNVD3.

rNVD3

This R package provides a familiar plotting interface for R users to create interactive visualizations using NVD3.js.

Installation

You can install rNVD3 from github using the devtools package

require(devtools)
install_github('rNVD3', 'ramnathv')

Usage

rNVD3 uses a formula interface to specify plots, just like the lattice package. Here is an example that you can try in your R console

hair_eye = subset(as.data.frame(HairEyeColor), Sex == "Female")
p1 <- nvd3Plot(Freq ~ Hair | Eye, data = hair_eye, type = 'multiBarChart')
p1$chart(color = c('brown', 'blue', '#594c26', 'green'))
p1
p1$save('haireye.html')

rNVD3 is also compatible with Slidify. Here is a slide deck with examples. Note that rNVD3 plots work best in Google Chrome.

More documentation is underway.

Using with Shiny

## server.r
require(rNVD3)
shinyServer(function(input, output) {
  output$myChart <- renderChart({
    hair_eye = as.data.frame(HairEyeColor)
    p6 <- nvd3Plot(Freq ~ Hair | Eye, data = subset(hair_eye, Sex == input$gender), 
      type = input$type, id = 'myChart', width = 800)
    p6$chart(color = c('brown', 'blue', '#594c26', 'green'), stacked = input$stack)
    return(p6)
  })
})

## ui.R
require(rNVD3)
shinyUI(pageWithSidebar(
  headerPanel("rNVD3: Interactive Charts from R using NVD3.js"),
  
  sidebarPanel(
    selectInput(inputId = "gender",
      label = "Choose Gender",
      choices = c("Male", "Female"),
      selected = "Male"),
    selectInput(inputId = "type",
      label = "Choose Chart Type",
      choices = c("multiBarChart", "multiBarHorizontalChart"),
      selected = "multiBarChart"),
    checkboxInput(inputId = "stack",
      label = strong("Stack Bars?"),
      value = FALSE)
  ),
  mainPanel(
    showOutput("myChart")
  )
))

Credits

Most of the implementation in rNVD3 is inspired by rHighcharts and rVega. I have reused some code from these packages verbatim, and would like to acknowledge the efforts of its author Thomas Reinholdsson.

License

MIT

See Also

There has been a lot of interest recently in creating packages that allow R users to make use of Javascript charting libraries.

rnvd3's People

Contributors

balinjdl avatar ramnathv avatar

Stargazers

 avatar

Watchers

 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.