您需要設置。此全局選項 我有這個頭作爲標準配置爲我的文檔,改變它的要求:
### Set global and markdown global options
```{r global.options, include = TRUE}
knitr::opts_chunk$set(
cache = TRUE, # if TRUE knitr will cache the results to reuse in future knits
fig.width = 10, # the width for plots created by code chunk
fig.height = 10, # the height for plots created by code chunk
fig.align = 'center', # how to align graphics in the final doc. 'left', 'right', 'center'
fig.path = 'figs/', # file path to the directory where knitr shall store the graphics files
results = 'asis', # knitr will pass through results without reformatting them
echo = TRUE, # in FALSE knitr will not display code in the code chunk above it's results
message = TRUE, # if FALSE knitr will not display any messages generated by code
strip.white = TRUE, # if FALSE knitr will not remove white spaces at the beg or end of code chunk
warning = FALSE) # if FALSE knitr will not display any warning messages in the final document
```
另外,請檢查您在文檔開頭設置了輸出類型:
---
title: "blah-blah"
author: "Denis Rasulev"
date: "November 2015"
output: pdf_document
---
你能提供一個[可重現的例子](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)嗎?請注意,全局選項僅適用於在它們被設置的位置(AFAIK)之後的塊*。 –