Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a collapsible or foldable table in Rmarkdown

Tags:

r

r-markdown

Hi I want to present some data with group of people using rmarkdown

some table is large, say 100+ lines, and not all the people want to view so much detail, they may only need to check first 20 lines of the table

So is there a way to show at the beginning 20 rows of the table, but if they want they can unfold the table to see the rest part of the table?

like image 951
cloudscomputes Avatar asked Oct 15 '25 04:10

cloudscomputes


1 Answers

You can use datatable from DT package.

For example:

DT::datatable(mtcars, options = list(pageLength = 20))

Shows only first 20 lines. And to show more lines you can change Select N entries.

enter image description here

like image 176
pogibas Avatar answered Oct 16 '25 17:10

pogibas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!