简体   繁体   English

如何在控制台中打印 RMarkdown 块代码 output?

[英]How to print RMarkdown chunk code output in Console?

As I test my R code in a chunk in R Markdown, I want all my print outputs to be shown in separate console window (not only below the code chunk, which is way down below, because my chunk is long – so I can't easily view it) As I test my R code in a chunk in R Markdown, I want all my print outputs to be shown in separate console window (not only below the code chunk, which is way down below, because my chunk is long – so I can' t 轻松查看)

I noted that in code below我注意到在下面的代码中

---
title: "How to  print rmarkdown code chunk output in Console?"
output: html_document
---

 ```{r}
 names(mtcars) 
 print(mtcars)

the print output of the first line is actually displayed both in Editor window below the chunk and in Console (see below)– that's great.第一行的打印 output 实际上显示在块下方的编辑器 window 和控制台中(见下文) - 这很棒。
However the print output of the second line (as of any list) is not shown in Console – and that's very inconvenient.然而,第二行的打印 output (与任何列表一样)未显示在控制台中 - 这非常不方便。

> names(mtcars) 
 [1] "mpg"  "cyl"  "disp" "hp"   "drat" "wt"   "qsec" "vs"   "am"   "gear"
[11] "carb"
> print(mtcars)

Is there a trick to address this inconvenience?有什么技巧可以解决这种不便吗?

Go to Tools > Global Options > R Markdown, and untick "Show output inline for all R Markdown documents". Go to Tools > Global Options > R Markdown, and untick "Show output inline for all R Markdown documents".

> names(mtcars)
 [1] "mpg"  "cyl"  "disp" "hp"   "drat" "wt"   "qsec" "vs"   "am"   "gear" "carb"
> print(head(mtcars))
                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 RStudio 中,如何像在控制台中一样在 quarto/rmarkdown 块中打印 tibble? - In RStudio, how to print tibble in quarto/rmarkdown chunk as in console? RMarkdown 不打印 RStudio 内的块 output - RMarkdown does not print chunk output inside RStudio 如何在Rmarkdown演示(slidy)中回显代码之前显示块输出? - How to display chunk output before echoing code in Rmarkdown presentation (slidy)? 在RMarkdown的输出中显示代码块名称 - Showing code chunk name in output in RMarkdown Rmarkdown:如何显示chunk的部分输出? - Rmarkdown: how to show partial output from chunk? 如何从代码块中的数据框中获取数字(或文本)到 RMarkdown html 输出中的文本? - How do I get a number (or text) from a data frame in a code chunk in to text in RMarkdown html output? 当 output 是来自代码块的文本时,如何在 Rmarkdown 中的每个注释之间添加一个空格? - How do I add a space between each comment in Rmarkdown when the output is text from a code chunk? 防止knitr / Rmarkdown与代码交错块输出 - prevent knitr/Rmarkdown from interleaving chunk output with code RMarkdown 将输出折叠成一个块 - RMarkdown collapse output in one chunk 如何在 rmarkdown 代码块的字符串中呈现 Z25F7E525B5C0641E1EB1FB3BDEBEB15B5Z 代码? - How to render latex code in a string from an rmarkdown code chunk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM