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

View source: R/epi_clean_make_names.R

epi_clean_make_namesR Documentation

Check and correct strings which are not syntactically valid or reserved

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

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 <\url{https://github.com/AntonioJBT/episcout}>

See Also

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

Examples


## 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 June 8, 2024, 7:47 a.m.