names2<-c("Ajay","Vijay","Rajesh","Arinjay","Ram")
gsub("jay","Ohjay",names2)
## [1] "AOhjay"    "ViOhjay"   "Rajesh"    "ArinOhjay" "Ram"
names3=toupper(names2)
names3
## [1] "AJAY"    "VIJAY"   "RAJESH"  "ARINJAY" "RAM"
grepl("jay",names3)
## [1] FALSE FALSE FALSE FALSE FALSE
library(stringr)
names4=str_to_upper(names2)
names4
## [1] "AJAY"    "VIJAY"   "RAJESH"  "ARINJAY" "RAM"
money=c("$50000","50,000",50000)
money2=gsub(",","",money)
money2
## [1] "$50000" "50000"  "50000"
money3=gsub("\\$","",money2)
money3
## [1] "50000" "50000" "50000"
money4=as.numeric(money3)
money4
## [1] 50000 50000 50000
names2
## [1] "Ajay"    "Vijay"   "Rajesh"  "Arinjay" "Ram"
names3
## [1] "AJAY"    "VIJAY"   "RAJESH"  "ARINJAY" "RAM"
paste(names2,names3)
## [1] "Ajay AJAY"       "Vijay VIJAY"     "Rajesh RAJESH"   "Arinjay ARINJAY"
## [5] "Ram RAM"
#names5=as.character(names2)
substr(names2,2,5)
## [1] "jay"  "ijay" "ajes" "rinj" "am"
names2
## [1] "Ajay"    "Vijay"   "Rajesh"  "Arinjay" "Ram"
nchar(names2)
## [1] 4 5 6 7 3
substr(names2,nchar(names2)-2,nchar(names2))
## [1] "jay" "jay" "esh" "jay" "Ram"
str_dup(names2,3)
## [1] "AjayAjayAjay"          "VijayVijayVijay"       "RajeshRajeshRajesh"   
## [4] "ArinjayArinjayArinjay" "RamRamRam"
names3<-c("   Ajay","Vijay  ","  Rajesh "," jayant","Ram")
names3
## [1] "   Ajay"   "Vijay  "   "  Rajesh " " jayant"   "Ram"
names4=str_trim(names3)
names4
## [1] "Ajay"   "Vijay"  "Rajesh" "jayant" "Ram"
str_pad(names4,width=20,side="both",pad=" ")
## [1] "        Ajay        " "       Vijay        " "       Rajesh       "
## [4] "       jayant       " "        Ram         "
nchar(str_pad(names4,width=20,side="both",pad=" "))
## [1] 20 20 20 20 20
str_c(names2,names3,sep="$$")
## [1] "Ajay$$   Ajay"     "Vijay$$Vijay  "    "Rajesh$$  Rajesh "
## [4] "Arinjay$$ jayant"  "Ram$$Ram"
str_length(names2)
## [1] 4 5 6 7 3
str_length(str_c(names2,names3,sep="$$"))
## [1] 13 14 17 16  8