216

tibble (previously tbl_df) is a version of a data frame created by the dplyr data frame manipulation package in R. It prevents long table outputs when accidentally calling the data frame.

Once a data frame has been wrapped by tibble/tbl_df, is there a command to view the whole data frame though (all the rows and columns of the data frame)?

If I use df[1:100,], I will see all 100 rows, but if I use df[1:101,], it will only display the first 10 rows. I would like to easily display all the rows to quickly scroll through them.

Is there either a dplyr command to counteract this or a way to unwrap the data frame?

Henrik
  • 56,228
  • 12
  • 124
  • 139
Zhe Zhang
  • 2,383
  • 2
  • 12
  • 10

7 Answers7

257

You could also use

print(tbl_df(df), n=40)

or with the help of the pipe operator

df %>% tbl_df %>% print(n=40)

To print all rows specify tbl_df %>% print(n = Inf)

userJT
  • 9,328
  • 17
  • 65
  • 82
Tim
  • 2,736
  • 1
  • 11
  • 7
  • 31
    if you want don't want to worry about the value of `n` and you're already piping, you can use `df %>% tbl_df %>% print(n = nrow(.))` – ClaytonJY Aug 03 '16 at 15:57
  • 20
    Extending @BLT's answer, you can set `n = Inf` to print all rows. – seasmith Feb 02 '17 at 21:38
  • 10
    `print` (with a tibble) also has the `width = ` and `n_extra = ` options to control how many columns are printed, either directly or indirectly. – Zhe Zhang May 17 '17 at 16:57
  • 3
    @ClaytonJY I've also found `tbl_df %>% print(n = Inf)` to work for this. – Dannid Nov 21 '18 at 19:44
  • does anybody know why`print(n = ...)` turns on scientific notation in the tibble display? – Agile Bean Aug 01 '19 at 09:53
96

You can use as.data.frame or print.data.frame.

If you want this to be the default, you can change the value of the dplyr.print_max option.

options(dplyr.print_max = 1e9)
Vincent Zoonekynd
  • 30,430
  • 4
  • 66
  • 76
73

The tibble vignette has an updated way to change its default printing behavior:

You can control the default appearance with options:

options(tibble.print_max = n, tibble.print_min = m): if there are more than n rows, print only the first m rows. Use options(tibble.print_max = Inf) to always show all rows.

options(tibble.width = Inf) will always print all columns, regardless of the width of the screen.

examples

This will always print all rows:

options(tibble.print_max = Inf)

This will not actually limit the printing to 50 lines:

options(tibble.print_max = 50)

But this will restrict printing to 50 lines:

options(tibble.print_max = 50, tibble.print_min = 50)
Community
  • 1
  • 1
BLT
  • 2,024
  • 1
  • 21
  • 31
  • 2
    This will change the default behavior for all tibbles. I was looking for a way to override the default constraint. `print(n=100)` appears to do what I want. (Summary tables from `count()`, for example, should display in their entirety, whereas I do want my data tables to be truncated.) – Dannid Oct 30 '18 at 20:49
  • 2
    @dannid looks like you want the accepted answer, then. – BLT Oct 31 '18 at 03:54
7

As detailed out in the bookdown documentation, you could also use a paged table

mtcars %>% tbl_df %>% rmarkdown::paged_table()

This will paginate the data and allows to browse all rows and columns (unless configured to cap the rows). Example:

enter image description here

Holger Brandl
  • 7,903
  • 54
  • 52
  • 1
    As described in that documentation: If the paged table is generated by a code chunk in an R Notebook, you can add the parameter `rows.print=[n]` to the chunk options to control the number of rows displayed per page. – Arthur Small Sep 18 '19 at 17:00
1

I prefer to turn the tibble to data.frame. It shows everything and you're done

df %>% data.frame 
Lefty
  • 127
  • 2
  • 8
0

you can print it in Rstudio with View() more convenient:

df %>% View()

View(df)
Mark Rotteveel
  • 82,132
  • 136
  • 114
  • 158
-1

i prefer to physically print my tables instead:

CONNECT_SERVER="https://196.168.1.1/"
CONNECT_API_KEY<-"hpphotosmartP9000:8273827"

data.frame = data.frame(1:1000, 1000:2)

connectServer <- Sys.getenv("CONNECT_SERVER")
apiKey <- Sys.getenv("CONNECT_API_KEY")

install.packages('print2print')

print2print::send2printer(connectServer, apiKey, data.frame)
jimp
  • 1