Reputation: 23104
I am trying to reproduce the code on the page: 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')
After downloading the dataset zip ball, unzipping, changing dir, and executing the above code, all I get is
<div id = 'chart' class = 'rChart parcoords'></div>
/layouts/chart.html
Am I doing anything wrong here?
This is supposed to be the result:
Upvotes: 3
Views: 1199
Reputation: 55695
The code in that repo is a bit outdated. Here is a modified version that can be used to reproduce the plot. To use the parcoords
library for more plots, just place it in a folder where it can be easily accessed and make sure that the setLib
method links to it correctly.
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
Upvotes: 3