How to create an interactive table in R

Interactive tables with looking and sorting can be a nice way of exploring facts. And at times, you could want to share that facts with other men and women — including textual content-only facts like a listing of Do Additional With R movie tutorials.

But when that facts involves a column with fairly extended entries, that column may well not fit effectively in a table the width of your monitor. This can be especially tricky when not each row involves the very-broad column. For case in point, a table of questionnaire benefits the place one discipline is “Do you have any additional opinions?” Not anyone may well.

Which is the place a table with expandable rows can appear in handy. At the NICAR facts journalism meeting before this calendar year, I posted a kind so speakers (and other attendees) could post one-way links to session shows. Some men and women included additional opinions others did not. Displaying that column by default would waste a lot of monitor serious estate.

As a substitute, that comment discipline shows in my interactive table of NICAR resources only if a consumer clicks on the increase-row icon. Not each row can be expanded with a clickable icon at the left of the Subject name mainly because not each row has facts in that discipline, as you can (hopefully) see in the screenshot down below.

table with expandable rows Sharon Machlis, IDG

R-created table with some rows that are expandable to display screen much more data. 

Let’s see how to make a table like this. 

If you’d like to adhere to together, put in and load the reactable bundle. For this demo, you will also need to have the rio, glue, htmltools, and dplyr offers mounted.

You can download the facts I’ll use in this demo from the connection down below. It’s a compact (fifteen rows) facts set about R and Python sessions at this year’s NICAR meeting.

Copyright © 2020 IDG Communications, Inc.

Leave a Reply

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