epi_clean_make_names: Check and correct strings which are not syntactically valid...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/epi_clean_make_names.R

Description

epi_clean_make_names() Pass a string vector such as column headers, check they are valid names and if not correct. Saves some headaches downstream when trying to plot non-syntactically valid column headers for example.

Usage

1
2
epi_clean_make_names(string = "", str_replacement = "_",
  unique = TRUE)

Arguments

string

String with names to test

str_replacement

string to use instead of the '.' from make.names() Default is '_'.

unique

make.names() unique parameter. Default is TRUE.

Value

A list of corrected and valid strings.

Author(s)

Antonio Berlanga-Taylor <https://github.com/AntonioJBT/episcout>

See Also

make.names, stackoverflow test if valid, r-bloggers test valid names.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
library(stringr)
string <- c('mean', '.j_j', '...', 'if',
'while', 'TRUE', 'NULL', '_jj',
'  j', '.2way')
valid_names <- epi_clean_make_names(string)
valid_names
epi_clean_make_names(valid_names) # There shouldn't be anything to correct

## End(Not run)

AntonioJBT/episcout documentation built on Nov. 7, 2019, 5:34 p.m.