我有一个本地图像,我想包含在一个.Rmd文件中,然后我将knit转换为HTML幻灯片Pandoc.根据这篇文章,这将插入本地图像:

有没有办法修改此代码以设置图像大小?
我试图在R markdown()文件中ggplotly从内部for循环中绘制一系列交互式图形.Rmd.我的.Rmd文件内容:
---
title: "Untitled"
output: html_document
---
```{r}
library(ggplot2) # for plots
library(plotly) # for interactive plots
# Convert 4 variables to factor variables:
factor_vars <- c("vs", "am", "gear", "carb")
mtcars[factor_vars] <- data.frame(Map(as.factor, mtcars[factor_vars]))
for (VAR in factor_vars) {
cat(paste("Factor variable:", VAR))
# Contents of "VAR" changes inside the loop
p <- ggplot(mtcars, aes_string(x = "mpg", y = "wt", color = VAR)) + geom_point()
# Print an interactive plot
print(ggplotly(p))
} …Run Code Online (Sandbox Code Playgroud) 有人可以解释为什么在Rmd代码中(使用RStudio生成HTML报告)下面只cat显示命令吗?当我将cat命令移到if子句之外或将其注释掉时,表格将被打印出来.我相信使用时会发生同样的事情library(printr),但我没有用最小的样本证实这一点.
似乎这个if子句中的代码以某种方式被解释在一起并且cat不能很好地解决datatable.
如果你能给我一些关于如何调试它的线索,它也会有所帮助.由于没有任何警告/错误消息.
---
title: "test"
output:
html_document
---
```{r}
if(TRUE){
DT::datatable(iris)
cat("I am here with my cat")
}
```
Run Code Online (Sandbox Code Playgroud) 我正在建造一个包含数字,文本和图表的表格.我用ggplot构建了我的情节,然后将它们添加到表格中(请参阅下面的代码).因为我(最终)会有很多情节,所以我需要使用循环来有效地创建它们.但是,由于ggplot似乎需要打印才能为每个绘图生成图像链接,我无法使用invisible(),随后在下面的图像顶部得到令人讨厌的'[ 1 ] [[2]] [[3]]'输出.
如何在不打印ggplot的任何可见输出的情况下编译文档?
```{r score_table, fig.show = "hide", echo = FALSE, fig.height=.75, fig.width=2.5}
#Load libraries
library(knitr)
library(ggplot2)
#Item data
items <- data.frame(text = sapply(1:3, FUN = function(x){
paste0(sample(x = LETTERS, size = 60, replace = T), collapse = "")}))
#Score data
score_set = replicate(n = 3, expr = {data.frame(other = rep("other", 4),
score=sample(1:7,4,TRUE))}, simplify = F)
#Plot function
plotgen<-function(score_set,other,score){
p <- ggplot(score_set, aes(factor(other), score))
p + geom_violin(fill = "#99CCFF") + coord_flip() + scale_x_discrete(name=NULL) +
scale_y_continuous(breaks …Run Code Online (Sandbox Code Playgroud) knitr ×4
r ×4
ggplot2 ×2
r-markdown ×2
datatable ×1
htmlwidgets ×1
image ×1
markdown ×1
pandoc ×1
plotly ×1