Error while plotting data in rchart using HighChart

橙三吉。 提交于 2019-12-11 06:40:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!