How to create tables in R with expandable rows

Interactive tables with hunting and sorting can be a nice way of exploring info. And at times, you may possibly want to share that info with other persons — like textual content-only info like a list of Do Additional With R movie tutorials.

But when that info involves a column with fairly long entries, that column could not healthy nicely in a desk the width of your display. This can be especially difficult when not each row involves the incredibly-extensive column. For example, a desk of questionnaire effects where by a person area is “Do you have any extra feedback?” Not anyone could.

Which is where by a desk with expandable rows can occur in helpful. At the NICAR info journalism conference before this yr, I posted a sort so speakers (and other attendees) could post inbound links to session displays. Some persons additional extra feedback others didn’t. Demonstrating that column by default would squander a whole lot of display true estate.

Instead, that comment area displays in my interactive desk of NICAR resources only if a person clicks on the broaden-row icon. Not each row can be expanded with a clickable icon at the still left of the Subject matter title mainly because not each row has info in that area, as you can (with any luck ,) see in the screenshot down below.

table with expandable rows Sharon Machlis, IDG

R-created desk with some rows that are expandable to exhibit far more details. 

Let us see how to make a desk like this. 

If you’d like to adhere to alongside, set up and load the reactable package. For this demo, you’ll also need to have the rio, glue, htmltools, and dplyr deals installed.

You can download the info I’ll use in this demo from the backlink down below. It’s a tiny (15 rows) info established about R and Python periods at this year’s NICAR conference.

Copyright © 2020 IDG Communications, Inc.

Leave a Reply

Your email address will not be published. Required fields are marked *