简体   繁体   English

针织 PDF Output 与 CAT in R

[英]Knit PDF Output with CAT in R

I am using CAT command in R to get following output.我在 R 中使用 CAT 命令来关注 output。

The Output in knitted PDF file is different to what I get in console.编织的 PDF 文件中的 Output 与我在控制台中得到的不同。 How can I get similar output in PDF as I get in Console?如何在控制台中获得类似 output 中的 PDF?

In PDF Output, the print question and code output is getting intermingled.在 PDF Output 中,打印问题和代码 output 混合在一起。

header <- blue$italic

cat(header("\nAre there any Missing Values ? \n"))
anyNA(cars_df)

cat(header("\nHow many Missing Values are there ? \n"))
sum(is.na(cars_df))

cat(header("\nWhich Variables have got Missing Values ? \n"))
colSums(is.na(cars_df))

R Studio Console Output R 工作室控制台 Output

R Studio 控制台输出

Knitted PDF Output针织PDF Output

针织 PDF 输出

I had the same issue but with html:我有同样的问题,但 html:

this>这个>

在此处输入图像描述

results in this ugly mess >结果导致这个丑陋的混乱>

在此处输入图像描述

Solution 1 is to use "hold" instead of "asis":=>解决方案 1 是使用“hold”而不是“asis”:=> 在此处输入图像描述 在此处输入图像描述

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM