问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/27034099/error-while-plotting-data-in-rchart-using-highchart