加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

使用knitr和rgl在html中包含3D交互式图形,在word / pdf中包含静

发布时间:2020-12-14 16:36:45 所属栏目:资源 来源:网络整理
导读:按照这个问题( including a interactive 3D figure with knitr)和Yihui( https://dl.dropboxusercontent.com/u/15335397/misc/webgl-rmd.html)的这个例子,我可以使用knitr和Rmarkdown在html输出中包含一个3D交互式图形.但我想在word / pdf输出中包含一个静态
按照这个问题( including a interactive 3D figure with knitr)和Yihui( https://dl.dropboxusercontent.com/u/15335397/misc/webgl-rmd.html)的这个例子,我可以使用knitr和Rmarkdown在html输出中包含一个3D交互式图形.但我想在word / pdf输出中包含一个静态图形.

是否有可能做到这一点?谢谢你的任何建议.

我的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

解决方法

您可以使用以下设置根据输出格式进行切换
```{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")
```

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读