【发布时间】:2015-10-29 16:32:57
【问题描述】:
我正在尝试在 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 中创建部分?
【问题讨论】:
-
你希望你的输出是什么样子的?为什么要在
cat中添加标题? -
输出应该在每个标题下,应该有对应的ggplot。