Table | the R Graph Gallery (2024)


Tables are an indispensable tool in data visualization. They offer a straightforward way to present complex data in an organized, easy-to-read format. R excels in table creation and manipulation, offering a range of packages like kableExtra, gt, reactable, and DT that provide extensive functionalities to suit various needs.
This section is rich in examples for each table-creation strategy, guiding you on which approach is best suited for different types of data and visualization goals.

How to make a table with R

Tables are powerful but complicated figures. As a result, there is a myriad of packages allowing to build them with R. It is easy to get lost!

I've tried to summarize the main packages in the following diagram:

Table | the R Graph Gallery (1)

The following document is organized following those 4 big families. For each package, I tried to explain when to use it and provided a few example with code to get started quickly.

1️⃣ GT, gtsummary and gtExtras

GT: Customizable, user-friendly R table

The GT package, stands for "Grammar of Tables". It was created by the RStudio team and first released in 2018. It offers an intuitive, tidyverse-inspired syntax, making table creation accessible, including for beginners.

GT's user-friendly design for handling complex formatting has quickly gained popularity in the R community. Its ease of use and readability make it a go-to choice for many R users seeking to create clear and aesthetically pleasing tables.

Introduction to gt A set of simple examples showing how to use the GT library.
Sub-headers How to create sub-headers with the gt library
Custom title A set of examples showing how to customize the titles of a table made with GT
Custom footer How to customize the footer and the references section of a gt table

gtsummary: summary statistics tables

gtSummary is a companion package to gt, specifically designed to enhance gt's capabilities in summarizing statistical findings. It bridges the gap between data analysis and table creation, allowing users to seamlessly generate summary tables directly from their analytical outputs.

By integrating with gt, gtSummary simplifies the process of transforming statistical results into well-organized and clear tables, ideal for reports or presentations.

Display regression results How to display results of your regression models in a beautiful table
Summary table Create summary table with both descriptive and inferential statistics, and even add your own custom functions!

gtExtras: more styling for gt

gtExtras augments and expands the functionalities of the gt package. It allows to create even more sophisticated and visually appealing tables.

It comes with a set of themes to make your table good-looking with just one more line of code. It provides functions to easily add plots in table cells. It also has helper functions to help with colors and icons.

Line chart Learn how to add a line chart in every cell of a table with gtExtras
Distribution With gtExtras, you can add a distribution plot in every cell, with multiple type of charts
Percentage bar How to add a percentage bar in a table cell with gtExtras
Summary table with charts Create summary table with descriptive statistics and charts with just one line of code!
Excel theme You can use a theme to make your table look like an Excel table
Dot matrix theme You can use a theme to make your table look like a dot matrix table
Dark theme You can use a theme to make your table look like a dark theme

2️⃣ kable and kableExtra for R Markdown documents

kable(): the table function of knitr

The knitr package is mainly made to render R Markdown documents. But it also has a kable() function that offers a simple and efficient way to create tables in R markdown documents.

kable() allows for quick conversion of data frames into tables.

kableExtra(): extending kable()

On the other hand, kableExtra serves as an extension to kable, significantly enhancing its capabilities. With kableExtra, users gain access to a wide range of styling and formatting options, such as adding stripes to rows, formatting text and cells, and even creating complex table layouts.

Customize colors in kableExtra tables Change background color, cell color or use a gradient of colors
Add links and images How to add links and images in a kableExtra table

3️⃣ Interactive tables with DT, reactable or formattable.

DT: easy filtering & sorting

DT stands for "DataTables", the Javascript library it interacts with. DT stands out for its ability to handle large datasets efficiently and its rich array of features like searching, sorting, and pagination.

I love adding a DT table at the beginning of my data analysis Quarto report. It provides access to your raw data easily!

Please check my full introduction to DT for more! Oh and this is how a DT table looks like:

See code

And a couple of additional examples to learn how to customize DT tables:

HTML content in table cells Add images, links, or any HTML content in a DT table
Filter, edit and add caption How to add a data-dependent filter, edit cell values and add caption to a DT table


reactable: unlimited cell customization

reactable allows to create interactive tables with extensive cell formatting capabilities.

It simplifies the process of embedding images within cells, it allows to create heat map-like tables through its advanced cell coloring features. Additionally, it offers unique functionalities for integrating bars or bubbles, further enhancing the visual appeal and informative value of the tables.

Reactable is also exceptionally effective for designing tables with expandable rows, making it an ideal choice for aggregating and presenting complex data sets in a user-friendly manner.

Column formatting How to format columns with date, currency or any numeric value in a reactable table
Clickable, interactive, and custom table How to create a fully customized table charts and clickable elements

Reactable can create some pretty amazing tables. Check this work by szymanskir for the R Studio table contest! Note: you can scroll, images are links, and the line chart is interactive.

See code

formattable

formattable is another great alternative when it comes to build interactive tables with R. Check its github repository for examples.

4️⃣ Other useful libraries.

flextable: best option for non-html output

flextable is another solid option to create very polish static tables. It supports a wide range of formatting options, including merging cells, rotating text, and conditional formatting.

It stands out due to its compatibility with various R Markdown formats, including Word, PowerPoint, and HTML.

rhandsontable: to manually edit cells

Rhandsontable provides an interactive table interface, allowing for direct editing of tables within a Shiny app or R Markdown document. It differentiates itself with features like dropdown menus, checkboxes, and calendar aids for data entry, emphasizing interactivity and user input.

It is best suited for applications requiring interactive data editing and manipulation within a web interface, such as Shiny applications.

modelsummary: for statistical model results

modelsummary is specialized for summarizing statistical models in R, offering a straightforward way to create elegant and comprehensive tables of model results.

It supports over one hundred types of models out-of-the-box, and allows users to report the results of those models side-by-side in a table, or in coefficient plots.

huxtable: for LaTeX output

huxtable focuses on creating simple yet elegant tables in R, with a strong emphasis on cross-format compatibility for LaTeX, HTML, and Word.

It is particularly appreciated by people in need for LaTeX outputs.

Related chart types

Barplot

Spider / Radar

Wordcloud

Parallel

Lollipop

Circular Barplot

Table | the R Graph Gallery (2024)

FAQs

What is a R graph gallery? ›

Welcome the R graph gallery, a collection of charts made with the R programming language. Hundreds of charts are displayed in several sections, always with their reproducible code available. The gallery makes a focus on the tidyverse and ggplot2.

How to make a table graph in R? ›

Plotting a table in R is a straightforward process. To do so, one must first create a data frame with the desired variables and values, and then use the command “plot” followed by the data frame and the desired type of plot.

What is R graph? ›

R offers a rich set of built-in functions and packages for creating various types of graphs. Graphs are a powerful tool for data visualization, enabling complex data patterns, trends, and relationships to be more comprehensible.

What is R used for in data visualization? ›

R is a programming language and environment for statistical computing, graphical data analysis, and scientific research. Using R as a data analytics platform lets developers and data scientists create various types of visualizations to represent complex, raw data with minimum coding.

How do you save an R graph as an image? ›

Plots panel –> Export –> Save as Image or Save as PDF

It's also possible to save the graph using R codes as follow: Specify files to save your image using a function such as jpeg(), png(), svg() or pdf(). Additional argument indicating the width and the height of the image can be also used.

What is the table function in R? ›

The table() function in R is a versatile tool that allows you to create frequency tables, also known as contingency tables, from categorical data. Its primary purpose is to summarize and organize the counts or frequencies of different unique values present within a vector, factor, or column of a data frame.

Can I create a table in R? ›

In R, these tables can be created using table() along with some of its variations. To use table(), simply add in the variables you want to tabulate separated by a comma.

What is the R bar chart used for? ›

Manufacturers typically use the X-bar and R-chart pair to visualize continuous data. The X-bar helps to monitor the average or the mean of the process and how this changed over time. The R-chart shows the sample range, which represents the difference between the highest and lowest value in each sample.

What is an R grid? ›

R-GRID: Artificial intelligence for the security of power grids – supported by the NATO Science for Peace and Security Programme. 11.04.2024. The main goal of the R-GRID project is to create an artificial intelligence tool to protect power grid systems.

What is graphical analysis in R? ›

Output: Stepped Line Graph for Graphical Data Analysis. In this example, we use the plot() function to create a stepped line graph of the “deaths” dataset. The type argument is set to “S” to specify a stepped line graph, and the main, xlab, and ylab arguments are used to add a title and axis labels to the plot.

References

Top Articles
Newly Engaged Josie Maran on Motherhood, Her Cosmetics Line, and an Important Message About Beauty
Josie Maran 24-Hour Flash Deal: Get $440 Worth of Products for Just $90 - E! Online
Www.paystubportal.com/7-11 Login
Craigslist St. Paul
Methstreams Boxing Stream
Craigslist Campers Greenville Sc
Jailbase Orlando
80 For Brady Showtimes Near Marcus Point Cinema
Toyota Campers For Sale Craigslist
Caroline Cps.powerschool.com
Osrs But Damage
What's New on Hulu in October 2023
Danielle Longet
All Obituaries | Ashley's J H Williams & Sons, Inc. | Selma AL funeral home and cremation
R Tiktoksweets
The Weather Channel Facebook
Erskine Plus Portal
Minecraft Jar Google Drive
Rachel Griffin Bikini
Napa Autocare Locator
Ups Access Point Lockers
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Qual o significado log out?
College Basketball Picks: NCAAB Picks Against The Spread | Pickswise
Egizi Funeral Home Turnersville Nj
Parkeren Emmen | Reserveren vanaf €9,25 per dag | Q-Park
Busted Mugshots Paducah Ky
Table To Formula Calculator
Studentvue Calexico
Wolfwalkers 123Movies
Speechwire Login
134 Paige St. Owego Ny
Haunted Mansion Showtimes Near Cinemark Tinseltown Usa And Imax
Newsday Brains Only
Morlan Chevrolet Sikeston
The Pretty Kitty Tanglewood
A Man Called Otto Showtimes Near Amc Muncie 12
KM to M (Kilometer to Meter) Converter, 1 km is 1000 m
Aliciabibs
Stafford Rotoworld
Dollar Tree's 1,000 store closure tells the perils of poor acquisitions
Keir Starmer looks to Italy on how to stop migrant boats
M Life Insider
Noaa Duluth Mn
VPN Free - Betternet Unlimited VPN Proxy - Chrome Web Store
26 Best & Fun Things to Do in Saginaw (MI)
Haunted Mansion Showtimes Near Millstone 14
Enjoy Piggie Pie Crossword Clue
Germany’s intensely private and immensely wealthy Reimann family
Bbwcumdreams
Okta Hendrick Login
Superecchll
Latest Posts
Article information

Author: Dean Jakubowski Ret

Last Updated:

Views: 6005

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Dean Jakubowski Ret

Birthday: 1996-05-10

Address: Apt. 425 4346 Santiago Islands, Shariside, AK 38830-1874

Phone: +96313309894162

Job: Legacy Sales Designer

Hobby: Baseball, Wood carving, Candle making, Jigsaw puzzles, Lacemaking, Parkour, Drawing

Introduction: My name is Dean Jakubowski Ret, I am a enthusiastic, friendly, homely, handsome, zealous, brainy, elegant person who loves writing and wants to share my knowledge and understanding with you.