It’s been a while since my last post. It’s time to catch up!

This one is short. Every time I write a paper or report, I need to create descriptive tables using Latex. Over and over I create these Adhoc tables, I say to myself:
Write a general function so you can save time in the next paper!
I know there are some solutions out there, but in general, I feel they are not flexible enough.

I introduce a far from perfect function to create descriptive tables in Latex. The steps and structure are quite simple:

Write a function to summarize your data with any stats you want

Define a list with the data plus column names (labels)

That’s it. Some useful features of the function:

It deals automatically with factors (categorical variables)

You can use different datasets at the same time

You can group columns using a variable (e.g., year)

You can add long notes at the bottom of the table

You can specify your descriptive function

Let’s start creating some fake data:

5 variables

Variable 3 is a factor (i.e., categorical)

Variable 5 is a grouping column

We can define a descriptive function:

Thus, the grouping of rows is defined by the name of each dataset in the list. We can add a note,
just remember to add \usepackage[flushleft]{threeparttable} to your Latex document:

We can also slice the descriptives by group:

It’s just a first version. I am adding more features in the future.