RNVD3
Interactive Charts from R using NVD3.js
Install / Use
/learn @ramnathv/RNVD3README
<b>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.</b>
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.
Related Skills
node-connect
353.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
