Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Interactive Charts from R using NVD3.js
branch: master
Failed to load latest commit information.
R revert width to 900
inst modify sample shiny app
.Rbuildignore initial commit
.gitignore add inst/docs to gitignore
DESCRIPTION initial commit
NAMESPACE initial commit
README.md add deprecation message and link to rcharts.

README.md

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.

Something went wrong with that request. Please try again.