How to replace the data


#1
  1. Consider the vector x=c(”apple”,”banana”,”grape”)
    Replace the first occurrence of a with ‘$’
    Can anyone please tell me how to write code for the above problem

#2

Hi, if u want just the first occurrence, simply: x <- sub(“a”,"$",x).
For all the “a”, use gsub.