Reputation: 75
I'm creating a data analysis report using Markdown, knitr.
When I run a code chunk 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 outputs a lot of white space, and I'm trying to provide as condensed an output as possible since these reports need to be printed. These extra lines add up to be a lot of extra pages.
As far as I've seen, this seems to happen only with tables, and not with other code. It seems that table()
is causing the problem by inserting the extra line above the table. Any way to disable this quirk?
Upvotes: 5
Views: 118
Reputation: 726
I believe table()
is printing a blank line for your dimension names. If you specify dnn=NULL
, it should go away.
addmargins(table(x$gender, exclude=NULL, dnn=NULL))
Upvotes: 4