dygraph in knitr not working

半世苍凉 提交于 2019-12-10 17:47:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!