R-fragment of an extra line in Markdown

I am creating a data analysis report using Markdown, knitr.

When I run a piece of code containing a table,

addmargins(table(x$gender, exclude=NULL))

This is what I get:

## 
## Female   Male   <NA>    Sum 
##     49     53      0    102

This is what I want:

## Female   Male   <NA>    Sum 
##     49     53      0    102

Markdown naturally draws a lot of gaps, and I try to provide as concise a conclusion as possible, as these reports must be printed. These extra lines contain many extra pages.

As far as I saw, this seems to only happen with tables, and not with other code. It seems to be table()causing the problem by inserting an extra row above the table. Any way to disable this quirk?

+4
source share
1 answer

, table() . dnn=NULL, .

addmargins(table(x$gender, exclude=NULL, dnn=NULL))
+3

Source: https://habr.com/ru/post/1612322/


All Articles