get_clean_names {libbib}R Documentation

Takes a data.frame and returns cleaned column names

Description

This function takes a data.frame, extracts the column names, and returns a vector of those column names but cleaned and stripped of potentially troublesome names

Usage

get_clean_names(dat, lower = TRUE)

Arguments

dat

A data.frame

lower

A logical indicating whether all column names should be made lower case (default TRUE).

Details

All space/whitespace characters are replaced with underscores, as are all characters not from A-Z, a-z, an underscore, or a digit

If there are duplicate column names after the cleaning, a message will show stating such and the duplicate column names will be make unique.

Value

Returns a vector of cleaned names

See Also

make.unique

Examples

ejemplo <- iris
names(ejemplo) <- c("Sepal Length", "Sepal@Width", "Petal	Length",
                    "Petal\\nWidth", "SpĂȘcies")
# c("sepal_length" "sepal_width"  "petallength"  "petal_nwidth" "sp_cies")

# c("Sepal_Length" "Sepal_Width"  "PetalLength"  "Petal_nWidth" "Sp_cies")


[Package libbib version 1.6.4 Index]