CatCorrJS with rCharts
来源:互联网 发布:巨人网络回归a股受益股 编辑:程序博客网 时间:2024/04/29 21:51
CatCorrJS with rCharts
CatCorrJS is a library that combines d3.js
and crossfilter.js
to make it easy to visualize relationships between categorical variables (e.g., results from a survey). This is an attempt to integrate it with rCharts.
The basic idea of the rCharts function integrating this library is to accept two csv files as inputs, one with the questions, and the other with the responses, and return an interactive visualization.
Inputs
The question file consists of three columns, representing type
of question, the text
content of the question and semicolon separated choices
. The response file is exported from Google Forms.
Visualization
The catCorrPlot
function reads the two csv files with questions and responses, processes the data to create a json payload that is accepted by the CatCorrJS library, and finally uses the rCharts
base class to produce an interactive visualization.
catCorrPlot <- function(questions_doc, responses_doc){
require(rCharts)
responses = read.csv(responses_doc)
responses = toJSONArray(setNames(
responses[,-1], 1:(NCOL(responses) - 1)
), json = F)
questions = read.csv(questions_doc, stringsAsFactors = F)
questions = lapply(1:NROW(questions), function(i){
qi = as.list(questions[i,])
qi$choices = strsplit(qi$choices, ";")[[1]]
qi$number = i
qi
})
questions = toJSONArray(questions, json = F)
r1 <- rCharts$new()
r1$setLib('http://rcharts.github.io/howitworks/catcorrjs/catcorrjs')
r1$set(questions = questions, responses = responses)
r1
}
We can now use this function to create an interactive visualization of the survey
r1 <- catCorrPlot("data/questions.csv", "data/responses.csv")
ToDos.
As an extension, I am working on a prototype, that would simplify workflow considerably by allowing a user to author a survey in RMarkdown, automagically create a google form based on it, and view the results as a dynamic interactive visualization.
Acknowledgements
All the heavy-lifting in creating this visualization is the work of Dean Malmgren and his awesome CatCorrJS. rCharts merely provides a wrapper to integrate this library into an #rstats workflow.
- CatCorrJS with rCharts
- slidify+rCharts+ECharts制作炫酷HTML5报告
- R语言如何安装rcharts包——Windows下
- 文本分析常用R包的安装(Rweibo、wordcloud、tm、tmcn、Rwordseg、Rcharts、xlsx、XLConnect)
- with
- with
- with
- oracle with
- oracle with
- js with
- with as
- WITH(NOLOCK)
- with as
- With (NoLock)
- WITH 查询
- with 语句
- with as
- start with
- thinkphp where的条件添加中,有变量的时候,里面用单引号就是不行;
- 4K对齐选8,2048和4098扇区数有多大区别?实测告诉你
- javaScript之cookies
- 升级应用编译SDK23版本的总结
- 二叉排序树/二叉查找树(Binary Search Tree)原理
- CatCorrJS with rCharts
- MFC中位图显示函数
- AsyncQueryHandler源码分析
- 前端面试题总结
- Hibernate的10个常见面试问题及答案
- websocket介绍
- js实现浏览器右下角弹出提示信息窗口,几秒后自动关闭
- Latin输入法怎么默认勾选几种语言
- spark on yarn