Interactive Charts from R using NVD3.js
This R package helps users create interactive visualizations with NVD3, using a plotting interface similar to the lattice package.
You can install rNVD3
from github
using the devtools
package
require(devtools)
install_github('rNVD3', 'ramnathv')
rNVD3
uses a plotting interface similar to that of the lattice
package. Here are a few examples you can try out in your R console.
require(rNVD3)
bar1 <- nvd3Plot(~gear, data = mtcars, type = "discreteBarChart", width = 600)
bar1$printChart("chart1")
hair_eye = subset(as.data.frame(HairEyeColor), Sex == "Female")
p1 <- nvd3Plot(Freq ~ Hair | Eye, data = hair_eye, type = 'multiBarChart', width = 600)
p1$chart(color = c('brown', 'blue', '#594c26', 'green'))
p1$printChart('chart2')
rNVD3
is merely a wrapper around nvd3.js. More documentation and examples are underway.
rCharts is compatible with Shiny. Here is a link to the rCharts Shiny App.
## 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")
)
))
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.
rNVD3
is licensed under the MIT License. NVD3 is licensed under Apache License, Version 2.0. You can read Read more about its license here