How to Make Beautiful Tables in R (2024)

Updated March 12, 2022 with info on the reactablefmtr and gtextras packages.

Want to learn to make beautiful tables?

Sign up for the course Making Beautiful Tables with R today!

It doesn't matter how good your data analysis is if you don't effectively communicate your results. In most reports, communication of results happens through a combination of data visualization and tables. Along with narrative text, these make up the bulk of content used to communicate results.

Clear writing is a topic for another venue. Data visualization in R is a huge topic (and one covered expertly in Kieran Healy's Data Visualization: A Practical Introduction and Claus Wilke's Fundamentals of Data Visualization). But what about tables? Fortunately for R users, there are many ways to create beautiful tables that effectively communicate your results.

Customizing Default Table Output in RMarkdown

If you are using RMarkdown (and, if you're not, you should really consider it), any data frame that you call in a code chunk is displayed using the data frame printing method set in your YAML. As Yihui Xie puts it, "printing objects in R code chunks basically emulates the R console." This default output leaves much to be desired. "Table" output with fixed-width fonts like this never inspired anyone to take action.

How to Make Beautiful Tables in R (1)

It is quite easy to improve this output. You can change the default data frame print method in the YAML to one of the following options.

How to Make Beautiful Tables in R (2)

Of these, the one most likely to improve your table output is paged, which creates paged tables that work well when you have particularly long tables and want to give users the ability to look at pieces of the output:

How to Make Beautiful Tables in R (3)

My Favorite R Packages to Make Tables

There are also many packages that provide functions to produce nicely formatted tables. Here are some of the packages I have used that produce tables that look good and effectively communicate results.

gt

gt is a new(ish) package. It “is designed to be both straightforward yet powerful … [with] an emphasis is on simple functions for the everyday display table needs.” The package has functions designed to do things like:

How to Make Beautiful Tables in R (4)

The gt package provides a general philosophy of tables (similar to the grammar of graphics theory that underlies the ggplot2 package) that enables it to be easy to use (with some practice) and extremely flexible.

Learn more about gt

gtextras

There’s also a package called gtextras that provides add-ons for the gt package. This package, by Thomas Mock, provides some nice themes like this modeled on New York Times tables.

How to Make Beautiful Tables in R (5)

The package also lets you add visualizations into tables, including sparklines and bar plots.

How to Make Beautiful Tables in R (6)

Learn more about gtextras.

kable + kableExtra

The kableExtra package builds on the kable output from the knitr package. As author Hao Zhu puts it:

The goal ofkableExtrais to help you build common complex tables and manipulate table styles. It imports the pipe%>%symbol frommagrittrand verbalize all the functions, so basically you can add “layers” to a kable output in a way that is similar withggplot2andplotly.

Sharla Gelfand used the kableExtra package in a report she did for the College of Nurses of Ontario and loved it.

How to Make Beautiful Tables in R (7)

Learn more about kableExtra

formattable

Kun Ren's formattable package" is designed for applying formatting on vectors and data frames to make data presentation easier, richer, more flexible and hopefully convey more information."

One of the most unique features is the ability to add colors, background shading, bars, and other features that move tables beyond hulking blocks of text.

How to Make Beautiful Tables in R (8)

If you're looking for an example of the formattable package in use, Laura Ellis has a really nice walkthrough.

Learn more about formattable

DT

The main appeal of the DT package is its ability to add filtering, pagination, and sorting to HTML tables. Users can slice, scroll through, and arrange tables in ways that help them to make sense of your results.

How to Make Beautiful Tables in R (9)

Learn more about DT

reactable

I had not heard of this package until Mara Averick tweeted about it recently. Though I haven't used it, the docs look incredible. Like the DT package, it offers the ability to sort and filter data. It's also much more visually appealing than the DT package. One of the examples (below) looks exactly like the gorgeous tables made by FiveThirtyEight.

How to Make Beautiful Tables in R (10)

Learn more about reactable

reactablefmtr

The reactable package can be a bit more challenging to work with. To simplify the process of creating tables in reactable, Kyle Cuilla developed the reactablefmtr package. As Kyle puts it:

The {reactablefmtr} package simplifies and enhances the styling and formatting of tables built with the {reactable}Rpackage. The {reactablefmtr} package provides many conditional formatters that are highly customizable and easy to use.

Among other things, the reactablefmtr package makes it easier to conditionally add colors to tables, add interactive sparklines, use custom themes, embed images in tables, and save tables in PNG and HTML format.

How to Make Beautiful Tables in R (11)

Learn more about reactablefmtr

flextable

The above packages are designed to produce HTML tables. If you are knitting to Word, your best for tables is the flextable package (though the tables this package produces can also be embedded within HTML and PDF outputs). Designed by David Gohel, the flextable package provides a straightforward syntax to shape the content and format of your tables.

How to Make Beautiful Tables in R (12)

Learn more about flextable

Packages Recommended by Others

The above packages are ones that I've used and had good success with. When I put the call out on Twitter for other packages to make tables in R, I got some promising-looking responses!

huxtable

The huxtable package produces:

LaTeX and HTML tables, with a friendly, modern interface. Features include control over text styling, number format, background color, borders, padding and alignment. Cells can span multiple rows and/or columns. Tables can be manipulated with standard R subsetting or dplyr functions.

How to Make Beautiful Tables in R (13)

Learn more about huxtable

rhandsontable

Like the DT package, the rhandsontable package gives users the ability to manipulate data in tables. It comes with "powerful features like data validation, sorting, grouping, data binding, formula support or column ordering." Working with tables feels like viewing data in Excel, which can be helpful for users used to working with Microsoft's ubiquitous spreadsheet program. Users can even make changes to data in tables made with this package.

How to Make Beautiful Tables in R (14)

Learn more about rhandsontable

pixiedust

The fantastically-named pixedust package is designed to produce a specific type of table: model output that has been tidied using the broom package. Using pixiedust is a three-step process:

  1. Run your model using a base R function (e.g. lm for a linear model)

  2. Use the tidy function from the broom package to convert the results into a tidy format

  3. Use the pixiedust package (the sprinkle_ set of functions in particular) to improve the output, removing “stats-speak” and putting it into a “format that is suitable for publication or submission to a client.”

The sprinkle_ functions enable you to do things like removing excess decimal places, convert p-values to not use scientific notation, and more.

How to Make Beautiful Tables in R (15)

If you want to ensure that end users read and understand the results of your complex statistical analyses, this looks like a great package!

Learn more about pixiedust

There are surely more table packages that I've missed (in wrapping up this post, I came across this list from the RStudio RMarkdown tutorials), but this should give you a good place to start in making your tables more beautiful and more effective.

How to Make Beautiful Tables in R (2024)

FAQs

How to get a nice table in R? ›

gtExtras : more styling for gt

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.

How can I make my table prettier? ›

Use colors and lines to help readers navigate your table. Highlight important cells by applying a subtle background color or group related values by creating thicker lines. Include the source of your data to make your table look more professional and allow readers to analyze the topic more deeply.

What is the best table package in R? ›

flextable (Gohel and Skintzos 2023) and huxtable (Hugh-Jones 2024): If you are looking for a table package that supports the widest range of output formats, flextable and huxtable are probably the two best choices.

How to use formattable R? ›

Method
  1. Select your table.
  2. Copy the name from Properties > GENERAL > Name.
  3. Select Calculation > Custom Code.
  4. Click onto the page to place the custom calculation.
  5. In the object inspector go to Properties > R CODE.
  6. Reference the formattable R library and define the table using the name from step 2.
Dec 20, 2022

How can I make my table look more interesting? ›

When deciding how to style and format your table, prioritize readability and remove any visual clutter that may distract the eye.
  1. Choose The Best Row Style. ...
  2. Use Clear Contrast. ...
  3. Add Visual Cues. ...
  4. Align Columns Properly. ...
  5. Use Tabular Numerals. ...
  6. Choose an Appropriate Line Height. ...
  7. Include Enough Padding. ...
  8. Use Subtext.
Oct 1, 2019

How do you set a classy table? ›

Place bread-and-butter plates above the forks, to the left of the place setting and don't remove them until the dessert course. Stemware is set above and to the right of the dinner plate. The water glass stands above the dinner knife, white wine to its right, and red wine top center.

How do you make a table look aesthetic? ›

Pick colours and things you like for aesthetic study table decoration. Use colourful pens, and stylish notebooks, and add cute decorations. A small plant can bring freshness, and keeping things organised with trays or containers makes it look neat.

How to make data tables look good? ›

Create Visual Hierarchy
  1. Use bold and slightly larger font sizes for column and row headers.
  2. Use shading to differentiate between headers and table content.
  3. “Zebra stripes” help create divisions between rows, making them easier to read.
  4. Use a contrasting color for links, so users know what content is clickable.
Jul 10, 2024

What makes a table more beautiful and attractive? ›

Use Linens. Adding linens instantly elevates your table setting. Consider a tablecloth, cloth napkins, and/or a table runner. Linens are an extra touch that won't go unnoticed by your guests and are a great foundation for setting the perfect table.

How to make simple tables 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.

Is data table better than tidyverse? ›

table and tidyverse . In cases when we are handling very large dataset, data. table would be a good choice since it runs extremely fast. In cases when we are not requiring the speed so much, especially when collaborating with others, we can choose tidyverse since its code is more readable.

What is the difference between Dataframes and tables in R? ›

frame in R is similar to the data table which is used to create tabular data but data table provides a lot more features than the data frame so, generally, all prefer the data. table instead of the data. frame.

What does formattable mean? ›

adjective. That can be formatted.

What is the function of Formattable? ›

This function creates a formattable data frame by attaching column or area formatters to the data frame. Each time the data frame is printed or converted to string representation, the formatter function will use the formatter functions to generate formatted cells.

How do I get the best table? ›

When you arrive at the restaurant, dress smartly and look the part - you are far more likely to get the best table if you dress to impress. Arrive early, or at least on time, and be polite to everyone when you arrive. Then ask again about the table if you've requested a specific one. If you are late, you might lose it.

How do you make a nice table in markdown? ›

A table is an arrangement of data in rows and columns. To add a table in Markdown, use the vertical line | to separate each column, and use three or more dashes --- to create each column's header. A vertical line should also be added at either end of the row. The output will look exactly the same.

How do you make an awesome table? ›

Create your first Awesome Table app
  1. Tutorial: Create your first Awesome Table app.
  2. Step 1: Create and set up your data source.
  3. Step 2: Create and set up a Table app in Awesome Table.
  4. Step 3: Customize how data is displayed in your app.
  5. Step 4: Embed your app on your website.

How do you make a good table? ›

Column and row headings
  1. Writing the headings. Tables are created using vertical columns and horizontal rows. ...
  2. Formatting and alignment. Align row headings on the left in the first column. ...
  3. Justify using a table. ...
  4. Stick to the essential information. ...
  5. Use notes. ...
  6. Use in-text references. ...
  7. Be consistent. ...
  8. Don't make it too long.

Top Articles
Shawnee County Detention Center KS Recent Arrests and Bookings
AVC Cup: Fifi Sharma hopes to sustain play after solid debut
O Riley Auto Parts Near Me
Citi Trends Watches
Dsw Designer Shoe Warehouse Ann Arbor Photos
Espn Transfer Portal Basketball
Sofia Pinkman
Ark Ragnarok Map Caves
Things to do in Wichita Falls on weekends 12-15 September
Large Storage Unit Nyt Crossword
888-490-1703
Ropro Cloud Play
Uhcs Patient Wallet
Maritime News Archives
Spirited Showtimes Near Gqt Kalamazoo 10
Budokai Z Pre Alpha Trello
Strange World Showtimes Near Marcus La Crosse Cinema
Downloahub
Lufkin Isd Calendar
Panic at the disco: Persona 4 Dancing All Night review | Technobubble
Best Internists In Ft-Lauderdale
Craigslist Manhattan Ks Personals
Cocaine Bear Showtimes Near Amc Braintree 10
Gcfysl
PoE Reave Build 3.25 - Path of Exile: Settlers of Kalguur
The Ultimate Guide To Beautiful Spokane, Washington
Lee Lucas Jaliyah Dad
Dishonored Subreddit
Lonesome Valley Barber
Pella Culver's Flavor Of The Day
10 Best-Performing Bi-Directional Scan Tools in 2023 (Full Control)
Belly Button Torture Video
Generac Find My Manual
9132976760
Mybackpack Bolles
Hyvee.com Login
Adams County 911 Live Incident
Keanu Reeves cements his place in action genre with ‘John Wick: Chapter 4’
T&J Agnes Theaters
Ucf Net Price Calculator
Usm.instructure
The Whale Showtimes Near Cinépolis Vista
Www.craiglist.com San Antonio
Bulk Amateur 51 Girls Statewins Leak – BASL058
What Is TAA Trade Agreements Act Compliance Trade Agreement Act Certification
How Old Is Ted Williams Fox News Contributor
Sam's Club Hiring Near Me
Oppenheimer Showtimes Near B&B Theatres Liberty Cinema 12
Used Cars For Sale in Pretoria | Quality Pre-Owned Cars | Citton Cars
About Data | Weather Underground
James in Spanish | Spanish to Go
Restaurants Near Defy Trampoline Park
Latest Posts
Article information

Author: Ouida Strosin DO

Last Updated:

Views: 6454

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Ouida Strosin DO

Birthday: 1995-04-27

Address: Suite 927 930 Kilback Radial, Candidaville, TN 87795

Phone: +8561498978366

Job: Legacy Manufacturing Specialist

Hobby: Singing, Mountain biking, Water sports, Water sports, Taxidermy, Polo, Pet

Introduction: My name is Ouida Strosin DO, I am a precious, combative, spotless, modern, spotless, beautiful, precious person who loves writing and wants to share my knowledge and understanding with you.