Introduction to parsetR

来源:互联网 发布:北京育知同创怎么样 编辑:程序博客网 时间:2024/06/17 13:17

Parallel Sets

Parallel sets first published by Robert Kosara in

Kosara, Robert, Fabian Bendix, and Helwig Hauser. “Parallel sets: Interactive exploration and visual analysis of categorical data.” Visualization and Computer Graphics, IEEE Transactions on 12.4 (2006): 558-568.

provide a compelling interactive method for visualizing categorical data.Jason Davies, co-author of d3.js, implemented an extremely well-designedd3 version of parallel sets. Using the infrastructure provided by htmlwidgets, this package parsetR allows us to easily integrate parallel sets into our R workflow.

Installation

parsetR is not on CRAN, so please install using devtools::install_github().

devtools::install_github("timelyportfolio/parsetR")

Usage

With table

In this first iteration, parsetR is designed to work with tables from R, such as the built-in Titanic dataset.

library(parsetR)
## Loading required package: vcdExtra## Loading required package: vcd## Loading required package: grid## Loading required package: gnm
parset(Titanic, width = "80%", height = 400)

Agealpha »size »C…AdultClassalpha »size »3rd1st2ndCrewSexalpha »size »MaleFemaleSurvivedalpha »size »NoYes

Here is another example with the UCBAdmissions data, and we’ll make the lines curvy with the tension argument.

library(parsetR)parset(UCBAdmissions, tension = 0.5, width = "80%", height = 400)

Admitalpha »size »AdmittedRejectedDeptalpha »size »ABCDEFGenderalpha »size »MaleFemale

With data.frame

With a data.frame you’ll need to tell parsetR where to find the numeric column for now. Otherwise, it will appear as a dimension. as shown below.

# demonstrate working with non-tabledata(Alligator, package="vcdExtra")# with data.frame to demo how it doesn't workparset(Alligator, width = "80%", height = 400)

countalpha »size »0123456789…foodalpha »size »reptilebirdinvertotherfishlakealpha »size »HancockOklawahaTraffordGeorgesexalpha »size »malefemalesizealpha »size »smalllarge

I thought it be fun to force a little JavaScript to specify our numeric value. I will eventually provide a more R-like interface, but for now please learn this tiny bit of JS :).

parset(  Alligator,  # dimensions are the categorical columns  dimensions = colnames(Alligator)[-5],  # use some JavaScript to inform parset that Freq has the value  value = htmlwidgets::JS("function(d){return d.count}"),  width = "80%", height = 400)

lakealpha »size »HancockOklawahaTraffordGeorgesexalpha »size »malefemalesizealpha »size »smalllargefoodalpha »size »fishinvertrept…bi…other

Feedback

parsetR was implemented in a couple of hours to provide a base for feedback, criticism, comments. Please help me make this thing as good as it should be.

0 0
原创粉丝点击