我正在尝试使用R-Markdown编织pdf文档。看来我遇到的问题与我尝试将直方图放入论文中直接相关。我试图在没有直方图的情况下编织文档,但它呈现得很好,但是一旦添加了直方图代码,我就不断遇到以下错误:
output file: Final_Version_1_-_Assignment_1_-_STA304.knit.md
! LaTeX Error: File `Final_Version_1_-_Assignment_1_-_STA304_files/figure-latex
/Q2_part_a_call' not found.
Error: Failed to compile Final_Version_1_-_Assignment_1_-_STA304.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See Final_Version_1_-_Assignment_1_-_STA304.log for more info.
Execution halted
以下是R-Markdown代码供参考:
---
title: "Stats - Assignment 1"
author: "John Doe"
date: "September 26, 2019"
output:
pdf_document: default
html_document: default
---
``{r setup, include=TRUE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
pop = c(1,0,0,4,1,6,6,3,5,3,1)
population = data.frame(pop)
``
Question 2) a) The following is a histogram of the population data:
``{r Q2_part_a_code, include = FALSE}
#Assignment 1 - Q2 - part a)
#Please enter the data frame being used and the column to be analyzed. Both without quotation marks.
population_histogram = function(df_for_use,column_to_analyze){
pop_histo = ggplot(data = df_for_use) + geom_histogram(mapping = aes(x = column_to_analyze), binwidth = 0.5)
print(pop_histo)
}
``
``{r Q2_part_a_call), include = TRUE}
population_histogram(population,pop)
``
注意:我在这里只打了两次勾号,这样代码块就不会与此页面上的markdown相冲突。我知道这是函数的三个滴答声。
如果我仅在R-Markdown窗口中执行代码,则代码工作正常,但是一旦尝试编织pdf,就会出现上述错误。
*编辑::经过更多测试之后,直方图绝对是一个问题。当我尝试编织MS Word文档时,它决定跳过直方图。它确实成功地将整个文档编织为html。