0

Trying to create a Morris chart with rMarkdown and send it to rPubs. However, I cannot get the chart to render:

```{r, results='asis', echo=FALSE, comment=NA}
library(rCharts)
library(ggplot2)
library(reshape2)
library(knitr)

summary(cars)

data=read.csv("prop by race.csv")


data$Poll=format(as.Date(data$Poll, "%m/%d/%Y"))


data=transform(data,White=White*100, Black=Black*100, Hispanic=Hispanic*100)


m1<-mPlot(x="Poll", postUnits="%",  smooth="false", y=c("White","Black","Hispanic"), type="Line", data=data, lineColors=c("darkblue","red","orange"))


m1$print('chart2',include_assets=TRUE, cdn=TRUE)

```

I get the following error:

pandoc.exe: Could not find data file //cdn.oesmith.co.uk/morris-0.4.2.min.css
Error: pandoc document conversion failed with error 97
In addition: Warning message:
running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" test_markdown.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_markdown.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\rcarvalho\Documents\R\win-library\3.1\rmarkdown\rmd\h\default.html" --variable "theme:bootstrap" --include-in-header "C:\Users\RCARVA~1\AppData\Local\Temp\Rtmp6rAH4a\rmarkdown-str2238e3c164f.html" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --no-highlight --variable "highlightjs=C:\Users\rcarvalho\Documents\R\win-library\3.1\rmarkdown\rmd\h\highlight"' had status 97 
Execution halted
vashts85
  • 1,069
  • 3
  • 14
  • 28

1 Answers1

0

You can get your chart properly rendered using the approach explained here:

2 Knitr/R Markdown/Rstudio issues: Highcharts and Morris.js

Your code chunk would be as follows using the morris.js example here:

http://timelyportfolio.github.io/rCharts_morris_gettingstarted/

```{r results = 'asis', comment = NA}
require(rCharts)
#specify the data
data = data.frame(
  c('2008', '2009', '2010', '2011', '2012'),
  c(20,10,5,5,20),
  stringsAsFactors = FALSE)

colnames(data) <- c("year","value")
#build the plot
m1 <- mPlot(
  x = "year",
  y = "value",
  data = data,
  type = "Line")
m1$set( labels = "value" ) 
m1$print('chart2', include_assets = TRUE)
```

For future questions try to include a reproducible data example (data=read.csv("prop by race.csv") is not reproducible).

Community
  • 1
  • 1
Jon Nagra
  • 1,538
  • 1
  • 16
  • 36