Search code examples
rrchartsgraphing

rRharts shows in Rstudio and browser but not R viewer


Morning Community,

I wanted to ask a quick question regarding rCharts graph outputs compared to native R.

Question 1: Why are graphs from rCharts displayed in my browser rather than the viewer in R?

Question 2: How can I force (or choose to use) the graphing function in native R instead?

See these two screen shots:

Code for native R:

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

Code for 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 Data used

   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: As an aside, I understand that I am graphing two different functions, a scatterplot vs radar plot. My goal is to understand whether or not native R can display (or perhaps another word) the graph output from rCharts - Even if I lose interactivity.


Solution

  • I have reached out to the developer for rCharts and he has replied back to me:

    "The native viewer that comes with the R GUI is NOT capable of displaying html. So, the only way to view html output like what rCharts generates is to use the browser. The RStudio viewer on the other hand is capable of displaying html and so rCharts takes advantage of that."