0

I am trying to integrate NVD3 in a Rmd file. When I run the sample code from the webpage, in the R terminal nothing happens:

hair_eye_male <- subset(as.data.frame(HairEyeColor), Sex == "Male")
n1 <- nPlot(Freq ~ Hair, group = "Eye", data = hair_eye_male, type = "multiBarChart")
n1$print("chart3")  # prints out code
n1  # nothing happens

The other examples do work, both in the terminal and in markdown, so this works:

```{r, cache=FALSE,results='asis'}
require(rCharts)
map3 <- Leaflet$new()
map3$setView(c(51.505, -0.09), zoom = 13)
map3$marker(c(51.5, -0.09), bindPopup = "<p> Hi. I am a popup </p>")
map3$marker(c(51.495, -0.083), bindPopup = "<p> Hi. I am another popup </p>")
# map3  # works, but truncates bottom part of frame in e.g. dimple.js
map3$show("inline", include_assets = TRUE, cdn = TRUE)

How can I get NVD3 to work in R? [RStudio 0.98.501, R 3.0.3, Xubuntu 13.10].

Henk
  • 3,634
  • 5
  • 28
  • 54
  • NVD3 charts may not show up in RStudio Preview if you are on Windows. Did you try opening it in a browser? – Ramnath Mar 22 '14 at 14:28
  • I could not reproduce your error in OS X 10.9.2, RStudio 0.98.703, R 3.0.3. The final `n1` in the first block produces the bar chart in my Chrome browser. – hrbrmstr Mar 22 '14 at 14:31
  • @Ramnath I am on Linux Xubuntu. I opened both Firefox and Chrome, nothing happens in NVD3, but all other D3 libraries work [in the RStudio viewer]. – Henk Mar 22 '14 at 15:25
  • @hrbrmstr None of the D3 charts open in a browser, they all [not NVD3] open in the RStudio viewer. – Henk Mar 22 '14 at 15:27
  • I am unable to reproduce your error either. Can you try saving the chart using `n1$save('myhtml')` and then manually opening it in your browser? – Ramnath Mar 22 '14 at 15:37
  • @Ramnath - that works, I can open the chart in Firefox. – Henk Mar 22 '14 at 16:35
  • How were you trying to open it before? Did you click the 'Open in Browser' icon in RStudio Viewer? If yes, what browser does it open it in? If you copy-paste the link in Chrome, does the chart show up? – Ramnath Mar 22 '14 at 16:49
  • Before the charts [not NVD3] opened in the RStudio viewer. I could also include them in markdown and open that in the browser. Both Chrome and Firefox work. I just discovered a little button in RStudio that says "Show in new window". That opens the NVD3 plot in a browser [Chromium in my case]. NVD3 is the only D3 chart with this behaviour, the others just open in the plot window of RStudio. – Henk Mar 22 '14 at 17:19

0 Answers0