I read a few questions and answers on this topic in a stack overflow, but still don't know how to solve this problem:
My goal is to convert the directory lines of files in Windows Explorer to a form that is recognized in R, for example. C: \ Users \ Public needs to be converted to C: / Users / Public, basically, one slash should be replaced by a slash. However, R was unable to save the original string "C: \ Users \ Public" because \ U and \ P are considered an escape character.
dirTransformer <- function(str){
str.trns <- gsub("\\", "/", str)
return(str.trns)
}
str <- "C:\Users\Public"
dirTransformer(str)
> Error: '\U' used without hex digits in character string starting ""C:\U"
What I am actually writing is a graphical interface where the end effect is that the user types or inserts a directory into the input field, presses a button, and then the program will automatically process it.
Someone please suggest me how to solve this problem?