Introduction to parsetR

红太狼 2022-09-21 13:09 135阅读 0赞

Kenton Russell

2015-09-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().

  1. 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.

  1. library(parsetR)
  2. ## Loading required package: vcdExtra
  3. ## Loading required package: vcd
  4. ## Loading required package: grid
  5. ## Loading required package: gnm
  6. 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.

  1. library(parsetR)
  2. 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.

  1. # demonstrate working with non-table
  2. data(Alligator, package="vcdExtra")
  3. # with data.frame to demo how it doesn't work
  4. parset(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 :).

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

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 条评论,135人围观)

还没有评论,来说两句吧...

相关阅读