Reputation: 1637
Whenever I print a dataframe in r markdown and knit it into html, the html always displays only 5 columns, before breaking, and printing the next 5 columns. Is there a way to set it to print more columns before breaking?
This post here shows how to it for rows but not for columns. I tried doing:
```{r chunk1, columns.print=7}
```
but it does not work and I can't seem to find any questions asked about this on stackoverflow. The reason for doing is that if I have a dataframe with for example 17 rows, it will print the dataframe in 4 breaks/paragraphs, which makes the html output very long and messy.
Upvotes: 2
Views: 1766
Reputation: 3242
You were so close, you need cols.print
NOT columns.print
and we need an extra YAML argument to allow for paging, to allow the user to see more of the data columns, if they want. I used 3 columns in my example to easily see the results.
---
title: "Untitled"
author: "Daniel"
date: "6/17/2021"
output:
html_document:
df_print: paged
---
```{r, cols.print=3}
mtcars
```
I would suggest using df_print: paged
as it allows for more dynamic tables for your document.
Upvotes: 3