2015-10-29 148 views
0

创建organizned部分我想包括在knitr部分,我看到一个奇怪的现象:你怎么knitr

这是文件的标题:


title: "cpu usage document" 
date: "October 29, 2015" 
output: 
    pdf_document: 
    number_sections: yes 
    toc: yes 
    toc_depth: 2 
    highlight: zenburn 
keep_tex: true 
--- 

在我有这样的事情块的一面:

cat("# cpu1 Bound \n") 
print(ggplot output here) 
cat("# memory1 Bound \n") 
print(ggplot output here) 
cat("# cpu2 Bound \n") 
print(ggplot output) 
cat("# memory2 Bound \n") 
print(ggplot output) 

当我编译knitr

我看到类似这样的东西。

1. cpu1 bound 
ggplot chart 
2.memory bound 
3.cpu2 bound 
4.memory2 bound 
ggplot output for memory1 
ggplot output for cpu2 
ggplot output for memory2 

我做错了什么?有没有更好的方法来创建knitr中的部分?

+2

你想要什么你的输出看起来像什么?你为什么把标题放在'cat'里? – A5C1D2H2I1M1N2O1R2T1

+0

输出应该在每个标题下,应该有相应的ggplot。 – user1471980

回答

1

使用正确的Markdown - 不要使用catprint

## cpu1 Bound 

```{r} 
ggplot output here 
``` 

## memory1 Bound 

```{r} 
ggplot output here 
``` 

## cpu2 Bound 

```{r} 
ggplot output here 
``` 

# memory2 Bound 

```{r} 
ggplot output here 
``` 

(另请注意,我用2级标题,如1级标题通常对应于文档的标题,因此应该只使用一次,一开始。)

+0

我必须使用猫和打印,其他智能它不适合我,我需要关闭评论等。 – user1471980

+0

我试过你的建议,而不是为我工作相同behaviror – user1471980

+0

@ user1471980这完全不清楚你是什么然后试图做。我的回答解决了您在问题下的评论提出的确切问题。 –