rRharts在Rstudio和浏览器中显示,但不在R viewer中显示

时间:2015-08-05 13:03:55

标签: r rcharts graphing

早上社区,

我想问一个与本地R相比rCharts图输出的快速问题。

问题1:为什么rCharts中的图形显示在浏览器中而不是R中的查看器中?

问题2:我如何强制(或选择使用)原生R中的图形功能?

请参阅以下两个屏幕截图:

原生R的代码:

# Simple Scatterplot
attach(mtcars)
plot(wt, mpg, main="Scatterplot Example", 
    xlab="Car Weight ", ylab="Miles Per Gallon ", pch=19)

rChart的代码:

library(rCharts)

myData

plot<-Highcharts$new()
plot$chart(polar = TRUE, type = "line",height=NULL)
plot$xAxis(categories=myData$Subject.ID, tickmarkPlacement= 'on', lineWidth=1)
plot$yAxis(gridLineInterpolation= 'circle', lineWidth=1, min=NULL,max=NULL,endOnTick=T,tickInterval=10)
plot$series(data = myData[,"A"],name = "A", pointPlacement="on")
plot

使用rChart数据

   Subject.ID  A  B  C
1           1 65 29 60
2           2 87 67 59
3           3 98 54 24
4           4 67 44 23
5           5 54 50  4
6           6 83 60 54
7           7 82 55 27
8           8 80 48 32
9           9 88 56 44
10         10 68 68 56
11         11 90 76 69
12         12 41 47 45
13         13 NA 82 NA
14         14 NA 55 NA

Ps:顺便说一下,我知道我正在绘制两个不同的函数,一个散点图和雷达图。我的目标是了解原生R是否可以显示(或者可能是另一个单词)rCharts输出的图形 - 即使我失去了交互性。

1 个答案:

答案 0 :(得分:1)

我已经联系了rCharts的开发人员,他回复了我:

&#34; R GUI附带的本机查看器无法显示html。因此,像rCharts生成的那样查看html输出的唯一方法是使用浏览器。另一方面,RStudio查看器能够显示html,因此rCharts利用了这一点。&#34;