简体   繁体   中英

Knit PDF Output with CAT in R

I am using CAT command in R to get following output.

The Output in knitted PDF file is different to what I get in console. How can I get similar output in PDF as I get in Console?

In PDF Output, the print question and code output is getting intermingled.

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 Studio 控制台输出

Knitted PDF Output

针织 PDF 输出

I had the same issue but with html:

this>

在此处输入图像描述

results in this ugly mess >

在此处输入图像描述

Solution 1 is to use "hold" instead of "asis":=> 在此处输入图像描述 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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