从rmarkdown生成的pdf中的文本而不是图像

时间:2016-11-16 04:15:01

标签: r knitr r-markdown knitr-spin

当我运行r-markdown代码生成PDF时,图像位置会显示文本。运行块并在“图”文件夹中生成pdf图像,但图像应在PDF中的文本为figure/unnamed-chunk-12.pdf

我以前从来没有这样做,并且已经成功生成了许多带有图像的pdf文件。似乎是在spin(file, format = 'Rmd', report=F)运行时,![plot of chunk unnamed-chunk-12]和括号不会放在md文件中。

为什么会出现这种情况以及我如何纠正它?

示例:

#' ---
#' title: "Testing the figure generation from 'spin'"
#' ---
#' ****
#+ echo=FALSE, eval = FALSE
    require(knitr)
    require(rmarkdown)
#+

#' # Background  
#' For some reason the plots don't show - they are missing text in the md file.
#' 
#+ echo=FALSE, message = FALSE, warning = FALSE
    plot(rnorm(100), rnorm(100))
#+  
#' But the text still works.  
#' 
#+ eval=FALSE, include = F
    file = "~/Desktop/TestSpinFigs.R" # THIS FILE
    setwd(dirname(file)); # Set the directory to be where the file is
    spin(file, format = 'Rmd', report=F) # Make a Markdown version
    render(paste(substring(file,0,(nchar(file)-1)),"md",sep=""), pdf_document(toc = TRUE, toc_depth=6, number_sections= TRUE), 
           output_file = paste(substring(file,0,(nchar(file)-2)),".pdf",sep="")) # Create the PDF
#+

呈现如下所示的pdf: rendered PDF

0 个答案:

没有答案