Reputation: 351
A possible duplicate of this unanswered question, adding code/screenshot here to hopefully clarify what the issue is.
When I run a chunk that outputs a data frame, I'm only getting one column per screen. I.e., running
library(tidyverse)
df %>%
select(col1, col2)
Produces the image below, where only col1 is displayed, and I have to click the arrow (not shown) to see the other column.
This seems to happen because col2 is a text field with several hundred characters, and so RStudio decides to give it as much real estate as possible, rather than placing it next to col1 (wasting all that space for the sake of displaying a handful of more characters).
Is it possible to override this setting? If so, can col2's output also be wrapped to screen width?
Upvotes: 0
Views: 539
Reputation: 4294
I use flextable
to control the width of columns printed on the screen, but you also have to make sure you don't select too many columns. For example, if col1
should be thin and col2
should be wide, do something like this:
library(flextable)
df %>% select(col1, col2) %>% regulartable() %>%
fontsize(size=8,part="all") %>% width(j=c(1:2),width=c(0.4,3))
The j
is flextable
's way of referring to columns, and the width
values are width in inches if you print the table in a doc or PDF.
Upvotes: 1