问题
I'm working on an R markdown file. The results of analysis are shown in the form of tibble
but in order to see all the columns and rows, I need to click to expand. However, since I'm going to knit the file into html, I need to display all the columns and rows in the R markdown file. I did a search and came up with the following codes:
options(tibble.width = Inf) # displays all columns.
options(tibble.print_max = Inf) # to show all the rows.
However, I don't know where to put them. I placed them before and after my code, but it didn't work. MY codes are:
head(df)
summarise(mean_cov= ..., median_cov=...., sd_cov=...., ...)
Thanks.
回答1:
a tibble
is a specific type of data.frame (try class(df)
), and it has its own method to print, which is frustrating when you want the full thing.
As it's still a data.frame though you can use the method for data.frames
and it will print everything, try:
print.data.frame(df)
or
print.data.frame(head(df))
or
print.data.frame(summarize...)
Note that as.data.frame
will have the same output
回答2:
print(your_tbl, n = 1e3)
or
your_tbl %>% print(n = 1e3)
Replace n
with a number larger than the max number of rows you'll encounter. (And hopefully 1e3 = 1000 will do, since a table with even 100 rows is pretty hard to understand by eye.)
来源:https://stackoverflow.com/questions/46994722/displaying-all-the-rows-and-columns-of-tibble-in-r-markdown