r - rCharts 中的平行坐标图,如何重现此图表?

标签 r data-visualization rcharts

我正在尝试重现页面上的代码:http://rcharts.io/parcoords/

cars <- read.csv('data/cars.csv')
p1 <- rCharts$new()
p1$field('lib', 'parcoords')
p1$set(padding = list(top = 24, left = 0, bottom = 12, right = 200))
p1$set(data = toJSONArray(cars, json = F), 
  colorby = 'economy', 
  range = range(cars$economy),
  colors = c('steelblue', 'brown')
)
p1$print('chart')

下载数据集zip ball,解压,更改目录,执行上面的代码后,得到的就是

<div id = 'chart' class = 'rChart parcoords'></div>
/layouts/chart.html

我是不是做错了什么?

应该是这样的结果:

enter image description here

最佳答案

那个 repo 中的代码有点过时了。这是可用于重现情节的修改版本。要将 parcoords 库用于更多绘图,只需将它放在一个可以轻松访问的文件夹中,并确保 setLib 方法正确链接到它。

library(downloader)
tf <- tempfile(fileext = ".zip")
download(
  url = "https://github.com/rcharts/parcoords/archive/gh-pages.zip",
  tf
)

# unzip to tempdir and set as working directory
td <- tempdir()
unzip(tf, exdir = td)
setwd(file.path(td, "parcoords-gh-pages"))

# read data
cars <- read.csv('data/cars.csv')

# initialize chart and set path to parcoords library
p1 <- rCharts$new()
p1$setLib("libraries/widgets/parcoords")

# add more details to the plot
p1$set(
  padding = list(top = 24, left = 0, bottom = 12, right = 200)
)
p1$set(
  data = toJSONArray(cars, json = F), 
  colorby = 'economy', 
  range = range(cars$economy),
  colors = c('steelblue', 'brown')
)
p1

关于r - rCharts 中的平行坐标图,如何重现此图表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23553397/

相关文章:

rChart nPlot - 更新 yAxis 标签

sqlite - 使用SQLite添加新列

d3.js - 从函数附加时文本元素不可见

javascript - 如何使用从 csv 文件过滤的数据创建多系列折线图?

r - 如何向 Shiny rCharts 图中添加回归线

rCharts - 像 gvisMerge 一样组合两个 rCharts

r - 自定义轴标签

r - 使用包 'rmongodb' 处理查询结果集

r - 生成 R ggplot 线图,其颜色/类型以不同变量为条件

javascript - 显示组间交叉表的分组条形图