问题
When trying to Knit my dygraph in R using Knitr:
library(dygraphs)
dygraph(nhtemp, main = "New Haven Temperatures") %>%
dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01"))
I get the following error:
## Error in validateCssUnit(sizeInfo$width): "\maxwidth" is not a
valid CSS unit (e.g., "100%", "400px", "auto")
Could anyone assist with how I can possibly fix this or what it means?
EDIT: Example code.
\documentclass{article}
\begin{document}
<<include=FALSE>>=
library(knitr)
options(width=55, formatR.arrow=TRUE, highlight=TRUE, scipen=1, digits=3, tidy=TRUE, comment='##') opts_chunk$set(fig.width=4, fig.height=4, fig.align='center', tidy=TRUE, highlight=TRUE, cache=TRUE, dev='tikz', fig.path='figure/', cache.path='cache/')
@
<<include=FALSE>>=
library(tikzDevice)
@
<<>>=
library(dygraphs)
dygraph(nhtemp, main = "New Haven Temperatures")
@
\end{document}
回答1:
Update: Starting from knitr 1.13 (not released yet), HTML widgets will be automatically converted to screenshots using the webshot package when the output format is not HTML.
dygraphs is an R package based on htmlwidgets (http://htmlwidgets.org), which means it only works for HTML output (e.g. from R Markdown documents or Shiny apps). You cannot use any htmlwidgets-based packages in LaTeX documents.
来源:https://stackoverflow.com/questions/31648139/dygraph-in-knitr-not-working