I wonder if I can use ggvis in .Rnw with knitr. I tried the following code in RStudio Version 0.98.1091
. But it is not working.
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm}
\begin{document}
\chapter{Test}
\begin{figure}[H]
<< label = Plot1, fig.lp = "Plot1", fig.cap = "Test Plot" >>=
library(ggvis)
p <- mtcars %>% ggvis(x = ~wt, y = ~mpg) %>% layer_points()
print(p) # Commenting this line will compile the document
@
\end{figure}
\end{document}
It throws the following error:
LaTeX errors:
! Missing $ inserted.
<inserted text>
$
l.70 \end{kframe}<!--html_
preserve--><div id="plot_id298740869-container" cl...
! Please use \mathaccent for accents in math mode.
Any help will be highly appreciated. Thanks
Edited
Commenting the line print(p)
will compile the document without any error.
Would be sufficient if there is a command like ggsave()
to save the ggvis
plots.