displaying all the rows and columns of tibble in R-markdown

丶灬走出姿态 提交于 2020-01-24 07:27:28

问题


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:

  1. head(df)
  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!