使用knitr和rgl在html中包含3D交互式图形,在word/pdf中包含静态图形 [英] Including a 3D interactive figure in html and static in word/pdf using knitr and rgl

查看:52
本文介绍了使用knitr和rgl在html中包含3D交互式图形,在word/pdf中包含静态图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下为问题(包括带有编织器的交互式3D图形)和益辉(

Following this question (including a interactive 3D figure with knitr) and this example by Yihui (https://dl.dropboxusercontent.com/u/15335397/misc/webgl-rmd.html), I can include a 3D interactive figure in html output using knitr and Rmarkdown. But I would like to include a static figure in word/pdf output.

是否可以这样做?感谢您的任何建议.

Is it possible to do this? Thanks for any suggestion.

我的sessionInfo

My sessionInfo

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rgl_0.95.1158 knitr_1.8    

loaded via a namespace (and not attached):
[1] evaluate_0.5.5 formatR_1.0    stringr_0.6.2  tools_3.1.1 

推荐答案

您可以使用以下设置根据输出格式进行切换

You could use the following setup to switch according to the output format

```{r, echo=FALSE}
out_type <- knitr::opts_knit$get("rmarkdown.pandoc.to")
keep <- if(out_type == "html") 'none' else 'last'
```


```{r chunk, echo=FALSE, fig.keep=keep}
plot(cars)
if(out_type == "html")
  cat("there goes fancy js code")
```

这篇关于使用knitr和rgl在html中包含3D交互式图形,在word/pdf中包含静态图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆