Skip to contents

Help mro variables extract common name out

Usage

substrsplit(obj, split_string = "")

Arguments

obj

It can be a vector or data frame, however, substrsplit is usually used in the iNZightMR function.

split_string

Specification of a string to allow splits on (e.g., use " " to only allow splitting at words).

Value

A list with common character and unique variable name respectively

Examples

substrsplit(c("varx", "vary", "varz"))
#> $Commonstr
#> [1] "var"
#> 
#> $Varname
#> [1] "x" "y" "z"
#> 

strings <- c("Do you like eating eggs?", "Do you like elephants?" , "Do you like elections?")
substrsplit(strings)
#> $Commonstr
#> [1] "Do you like e"
#> 
#> $Varname
#> [1] "ating eggs?" "lephants?"   "lections?"  
#> 
substrsplit(strings, split_string = " ")
#> $Commonstr
#> [1] "Do you like"
#> 
#> $Varname
#> [1] "eating eggs?" "elephants?"   "elections?"  
#>