string_to_var {naryn}R Documentation

Create a syntactically valid variable name from a string

Description

Spaces are replaced with '_' and other non valid characters are encoded as '.' + two bit hexadecimal representation. Variables which start with an underscore or a dot are prepended with the letter 'X'. The result is sent to make.names in order to deal with reserved words.

Usage

string_to_var(str)

Arguments

str

string

Details

Note that strings starting with 'X.' would not be translated back correctly using var_to_string, i.e. string_to_var(var_to_string("X.saba")) would result ".saba".

Value

a syntactically valid variable name

Examples

string_to_var("a & b")
string_to_var("saba and savta")
string_to_var("/home/mydir")
string_to_var("www.google.com")
string_to_var("my_variable + 3")
string_to_var(".hidden variable")
string_to_var("NULL")


[Package naryn version 2.6.26 Index]