hopnoggin
hopnoggin

Reputation: 23

Displaying dataframes in R Markdown

I can't find a method to remove the hash marks and row numbers from dataframes outputted to a word document in R markdown. I'd like to be able to present only the data without those features

Upvotes: 1

Views: 851

Answers (2)

Yorgos
Yorgos

Reputation: 30485

Check out the sjPlot package and specifically the view_df function

Upvotes: 1

r2evans
r2evans

Reputation: 161110

The knitr website and specifically the page on Chunk options suggests the use of a separate chunk (before your want to display a data.frame in this manner) to change the default for the chunk option comment, perhaps like this:

```{r global_options}
opts_chunk$set(comment = NA)     # default value is '##'
```

to disable the inserting of comment characters on output. Realize that this setting of the comment option is applicable to all chunks that follow this chunk; this chunk itself will not be affected by it.

This does give the textual representation of the data.frame (as if it were on the terminal), and not a more refined representation. I second @PierreLafortune's suggestion to look at knitr::kable.

Upvotes: 2

Related Questions