README.md

cleaneRnames

This and extremely simple, single-function package. The single goal of cleaneRnames is to improve the output of base::make.names in two ways:

Install

The easier way to install is via devtools:

# install.packages("devtools")
devtools::install_github("adomingues/cleaneRnames")

Example

This is a basic example which shows you how to solve a common problem:

## basic example code
some_col <- c(
    "I once",
    "got   some weird",
    "tables",
    "from.a.collaborator")

Using make.names each and every space will be converted to .:

make.names(some_col)

And using the package:

library(cleaneRnames)
clean_names(some_col)
clean_names(some_col, replace.all=F, sep="_")
clean_names(some_col, sep="_")
clean_names(some_col, sep="+")

Motivation and Goal

This package doesn't have lofty aspirations and it is merely an excuse to start writing R packages.

It all started with a tweet in which I was happy to have discovered how a simple base function, make.names could be so useful and yet unknown to me. Following some discussion it soon became clear that there was room for improvement. For instance, make.names used . to separate strings, and does not allow setting other separators. There are also some weird colnames with multiple spaces and each gets converted to an . resulting and syntactically valid R names but not very human-readable (see example above).

So I took the challenge by Ryan Estrellado and wrote a function/package.

The package janitor already does something similar, but since my primary goal was to write my first R package, I continued anyway if if there is duplicated functionality.

Credits

Special thanks to Ryan Estrellado for suggesting that this could turn into a package and the inclusion of sep=.

I read/used several tutorials packages that helped me immensely: - Jenny Brian's usethis - Karl Broman's R package primer



adomingues/cleaneRnames documentation built on May 11, 2019, 6:26 p.m.