Can you please help, how to write a function which change little letters to big and vice verse in R?
>Solution :
Example string
mystring = "This Is aN ExAmPlE sTRING"
See ?chartr for details but its used like this chartr(old,new,x). Here we are flipping the lower case and uppercase letters so the old is the reverse of the new and what we want to change (x) is the string.
Function:
myfunct <- function(string){
chartr("a-zA-Z", "A-Za-z",string)
}
call function:
myfunct(mystring)
Output:
[1] "tHIS iS An eXaMpLe String"