Rmd:有时打印到文档,有时打印到控制台

时间:2019-01-26 13:49:57

标签: r console r-markdown

我使用R编译Rmd文档(例如test.Rmd

>> library('rmarkdown');
>> rmarkdown::render('test.Rmd');

这是一个测试文档:

---
title: "Musterdokument für Rmd"
subtitle: "Testcase"
author:
- "Max Mustermann"
date: "2018-10-09"
output:
pdf_document:
editor_options:
chunk_output_type: console
---




# Introduction
This is a test document.

# My code
Here is a test R-script

```{r, test 1, eval=TRUE, results="show", echo=TRUE, message=FALSE, error=FALSE, warning=FALSE, comment=''}
options('digits'=6);

x <- runif(1);
print(x); # will be shown in the output document. How do I get it to display in the R-console too/instead?
```

```{r, test 2, eval=TRUE, results="hide", echo=TRUE, message=FALSE, error=FALSE, warning=FALSE, comment=''}
x <- runif(1);
print(x); # still doesn't work...
```

(我必须在这篇文章中进行缩进,以使```字符不会逃脱代码块。)

有时候我真的很想让东西打印到普通的R控制台例如菜单交互或只是普通的打印命令。但是一切似乎都直接进入了文档。有办法做到这两者吗?

0 个答案:

没有答案