Learn R Programming

clinCompare (version 1.0.0)

clean_dataset: Clean Dataset

Description

Removes duplicate rows, standardizes column names and text values to uppercase or lowercase, and performs basic data cleaning on a data frame.

Usage

clean_dataset(
  df,
  variables = NULL,
  remove_duplicates = TRUE,
  convert_to_case = NULL
)

Value

A cleaned data frame.

Arguments

df

A data frame to be cleaned.

variables

Optional; a vector of variable names to specifically clean. If NULL, applies cleaning to all variables.

remove_duplicates

Logical; whether to remove duplicate rows.

convert_to_case

Optional; convert character variables to "lower" or "upper" case.

Examples

Run this code
# \donttest{
  df <- data.frame(name = c("Alice", "Bob", "Alice"),
                   score = c(90, 85, 90),
                   stringsAsFactors = FALSE)
  clean_dataset(df, remove_duplicates = TRUE, convert_to_case = "upper")
# }

Run the code above in your browser using DataLab