TidyTuesday Section

Explore the week’s TidyTuesday challenge. Develop a research question, then answer it through a short data story with effective visualization(s). Provide sufficient background for readers to grasp your narrative.

Date: 2026-01-27 Data: Brazilian Companies Source: Open data CNPJ - December 2025 Article: Wikipedia’s List of largest Brazilian companies

Research Question:

What is the relationship between a Brazilian companies’ size and their legal nature?

Code
library(ggplot2)
library(tidyverse)
Code
companies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2026/2026-01-27/companies.csv')
legal_nature <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2026/2026-01-27/legal_nature.csv')
qualifications <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2026/2026-01-27/qualifications.csv')
size <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2026/2026-01-27/size.csv')
Code
companies_clean <- companies |> 
  mutate(companysizeclean = case_when(
    company_size == "micro-enterprise" ~ "Micro",
    company_size == "small-enterprise" ~ "Small",
    company_size == "other" ~ "Other"
  ))

companies_clean |> 
  group_by(legal_nature) |> 
  summarize(n())
# A tibble: 22 × 2
   legal_nature                                     `n()`
   <chr>                                            <int>
 1 Autonomous Social Service                            1
 2 Brazilian Branch of a Foreign Company                5
 3 Consumer Cooperatives                                1
 4 Cooperative                                         78
 5 General Partnership                                  8
 6 Individual Limited Liability Company (Business)    182
 7 Individual Limited Liability Company (Simple)        1
 8 Individual Real Estate Company                      50
 9 Limited Liability Business Company (LLC)        119288
10 Mixed-Capital Company                               21
# ℹ 12 more rows
Code
companies_clean <- companies_clean |> 
  filter(legal_nature != "Autonomous Social Service" &
           legal_nature != "Brazilian Branch of a Foreign Company" &
           legal_nature != "Consumer Cooperatives" &
           legal_nature != "General Partnership" &
           legal_nature != "Individual Limited Liability Company (Simple)" &
           legal_nature != "Individual Limited Liability Company (Business)" &
           legal_nature != "Cooperative" &
           legal_nature != "Individual Real Estate Company" &
           legal_nature != "Partnership Limited by Shares" &
           legal_nature != "Simple General Partnership" &
           legal_nature != "Private Association")
Code
companies_clean |> 
  ggplot(aes(x = companysizeclean, fill = legal_nature)) +
  geom_bar() +
  labs(x = "Company Size", y = "Companies by Legal Nature", fill = "Legal Nature", 
       title = "Brazilian Company Size and Legal Nature", 
       subtitle = "Micro companies dominate Brazil, and LLCs are the most popular company legal nature.", 
       caption = "Source: Open Data CNPJ | Feb. 16, 2026 | Katherine Manuel") +
  scale_fill_viridis_d() +
  theme_bw() +
  scale_y_continuous(labels = scales::label_comma()) +
  theme(legend.position = "bottom") +
  guides(fill = guide_legend(nrow = 3, byrow = TRUE))

A bar graph detailing how legal nature varies by company size in Brazil. It shows that the majority of companies file as Limited Liability Business Companies (LLCs), with Sole Proprietorships being the second most popular legal nature overall. Micro companies are the most common.