Skip to content

Single function R package to clean the output of base::make.names

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

adomingues/cleaneRnames

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • replace multiple spaces with a simple separator.
  • add an option to use user defined separator.

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:

About

Single function R package to clean the output of base::make.names

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages