Manish
Manish

Reputation: 3521

Error while plotting data in rchart using HighChart

I am reading data from file and plotting data using rchart/highchart but i am getting following Error.

sampledata

A   B   C
2   3   0
4   5   0
4   -3   1
-8   5   1
2   -3   2
-2   -5   2
12   3   3
-4   5   3

R Scitpt:

require(devtools)
install_github(’rCharts’ ,’ramnathv’)
sampledata<-read.csv("data.csv",header=TRUE,sep="\t")
h1 <- hPlot(x = sampledata[1,], y = sampledata[2,], data = sampledata, type = "scatter", group=sampledata[3,])

Error in .subset2(x, i, exact = exact) : invalid subscript type 'list'

How can i plot scatter plot using rcharts by calling Highcharts internally?

Upvotes: 1

Views: 253

Answers (1)

user2357031
user2357031

Reputation:

Assuming your column names in the sampledata are A, B and C, this should work:

h1 <- hPlot(x = 'A', y = 'B', data = sampledata, type = "scatter", group='C') 

Function hPlot does not want to get the actual data values. Instead, you should give as an input the names of columns you want to plot. Alternatively, you can also use a formula interface. For example, see, https://github.com/ramnathv/rCharts/blob/master/inst/libraries/highcharts/examples.R.

Upvotes: 2

Related Questions