Reactable and reactablefmtr

R packages for creating interactive data tables

By Irene van den Broek in Sleep Activity

June 20, 2021

I tested the {reactable} package to create an interactive table for my Sleep, Activity, and Readiness scores from the Ōura ring. The {reactablefmtr}, {tippy} and {sparkline} package further facilitated the complete customization of the table.

Sleep, activity and readiness scores

Measured with Oura Ring between 2020-01-30 and 2022-11-04 (1010 days)

© JeBentWatJeMeet 2021

Reactable

The {reactable} package is an R package created by Greg Lin based on the React Table library and made with reactR. With {reactable} you can easily create interactive data tables with options for e.g., sorting, filtering, and pagination.

The colDef() function defines the customization of each column in the table. The aggregate argument was used to group rows by Score type. Grouping by Activity, Sleep or Readiness was enabled with the groupBy argument in the reactable() function.

For every column, the cell argument defines the cell rendering. The cell argument can be an R function as well as a JS() function. As the latter seemed complicated, I was glad to discover the {reactablefmtr} package that provides various easy-to-use and highly customizable functions to render features such as databars, sparklines or icons.

Reactablefmtr

The {reactablefmtr} package is an R package created by Kyle Cuilla that streamlines and enhances the styling and formatting of tables built with the {reactable} package, providing many conditional formatters that are highly customizable and easy to use.

For example, the data_bars() and icon_sets() functions in the cell argument were used to create the data bars and icons in the Last value and Trend column, respectively. Some other useful functions from the {reactablefmtr} package include the add_title() and add_subtitle() functions to easily prepend a (sub)title to the table.

Sparkline

Although the {reactablefmtr} package also offers a react_sparkline() function to enable easy rendering of sparklines, I couldn’t really get it to work and, therefore, created a custom function using the sparkline() function from the {sparkline} package. With this function, the tiny bar chart showing the trend of the last 14 days, as well as the boxplots showing the distribution of all scores were created.

Tippy

Finally, I used the {tippy} package from John Coene to show the individual values when hoovering over the data bars in the Trend column.

Posted on:
June 20, 2021
Length:
3 minute read, 614 words
Categories:
Sleep Activity
Tags:
Oura Ring reactable Interactive charts
See Also:
Ōura Ring
echarts4r