使用HighChart绘制rchart中的数据时出错 [英] Error while plotting data in rchart using HighChart

查看:122
本文介绍了使用HighChart绘制rchart中的数据时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用rchart / highchart读取文件中的数据并绘制数据,但是我收到了错误消息。

sampledata

  ABC 
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,])

在.subset2中的错误(x,i,exact = exact):无效的下标类型'list'

如何在内部调用Highcharts来绘制使用rcharts的散点图?

解决方案

假设您的samplesata中的列名是A,B和C,这应该可行:

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

函数 hPlot 不想获取实际的数据值。相反,您应该输入想要绘制的列的名称。或者,您也可以使用公式界面。例如,请参阅 https://github.com/ ramnathv / rCharts /斑点/主/安装/库/ highcharts / examples.R

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?

解决方案

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.

这篇关于使用HighChart绘制rchart中的数据时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆