Skip to content
Back to skills

Janitor

ASecurity

R janitor package for data cleaning. Use for cleaning dirty data and creating tabulations.

  • 5 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added June 4, 2026
datago

Security analysis

A100/100

Scanned June 4, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill janitor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Janitor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Janitor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-janitor/badge)](https://www.skillsdirectory.com/skills/leolin990405-janitor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: janitor
description: R janitor package for data cleaning. Use for cleaning dirty data and creating tabulations.
---

# janitor

Simple tools for examining and cleaning dirty data.

## Clean Names

```r
library(janitor)

# Clean column names
df <- clean_names(df)

# Options
df <- clean_names(df, case = "snake")      # default
df <- clean_names(df, case = "lower_camel")
df <- clean_names(df, case = "upper_camel")
df <- clean_names(df, case = "screaming_snake")
df <- clean_names(df, case = "title")

# Make names from vector
make_clean_names(c("First Name", "Last Name"))
```

## Tabulations

```r
# One-way tabulation
df %>% tabyl(category)

# Two-way tabulation
df %>% tabyl(category, group)

# Three-way tabulation
df %>% tabyl(category, group, year)
```

## Tabyl Adornments

```r
df %>%
  tabyl(category, group) %>%
  adorn_totals("row") %>%           # Add row totals
  adorn_totals("col") %>%           # Add column totals
  adorn_percentages("row") %>%      # Convert to row percentages
  adorn_pct_formatting() %>%        # Format percentages
  adorn_ns() %>%                    # Add counts in parentheses
  adorn_title("combined")           # Add title row
```

## Remove Empty

```r
# Remove empty rows and columns
df <- remove_empty(df, which = c("rows", "cols"))

# Remove empty rows only
df <- remove_empty(df, which = "rows")

# Remove empty columns only
df <- remove_empty(df, which = "cols")

# Remove constant columns
df <- remove_constant(df)
```

## Duplicates

```r
# Find duplicates
df %>% get_dupes()

# Find duplicates by specific columns
df %>% get_dupes(name, date)

# Count duplicates
df %>% get_dupes() %>% nrow()
```

## Data Comparison

```r
# Compare data frames
compare_df_cols(df1, df2)

# Check if same columns
compare_df_cols_same(df1, df2)
```

## Excel Dates

```r
# Convert Excel numeric dates
excel_numeric_to_date(44197)  # Returns Date

# Convert Excel datetime
excel_numeric_to_date(44197.5, include_time = TRUE)

# Convert to Excel date
convert_to_date("2021-01-01")
convert_to_datetime("2021-01-01 12:00:00")
```

## Rounding

```r
# Round half up (Excel-style)
round_half_up(2.5)  # Returns 3

# Round to fraction
round_to_fraction(0.37, denominator = 4)  # Returns 0.25
```

## Row-wise Operations

```r
# Add row numbers
df %>% row_to_names(row_number = 1)  # Use first row as names

# Convert first row to names
df %>% row_to_names(1)
```

## Crosstab

```r
# Cross tabulation with statistics
df %>%
  tabyl(var1, var2) %>%
  chisq.test()

# Fisher's exact test
df %>%
  tabyl(var1, var2) %>%
  fisher.test()
```

## Top Levels

```r
# Show top levels of factor
df %>% top_levels(category, n = 5)
```

## Single Value

```r
# Check if column has single value
df %>%
  summarise(across(everything(), ~ n_distinct(.x) == 1))
```

## With dplyr

```r
library(dplyr)

df %>%
  clean_names() %>%
  remove_empty(c("rows", "cols")) %>%
  mutate(date = excel_numeric_to_date(date_col)) %>%
  tabyl(category) %>%
  adorn_pct_formatting()
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.