I was thinking that someone has come to the R while cleaning the data to solve this problem. For example, list of strings:
strings = c ("Hello World", "Goodbye all", "Help is appreciated", "Hello Sam")
< / Pre>Then we can go through the list of strings and whenever a certain word is found, the whole string will be changed.
So if we are searching for the word "hello" then it will be "mathematics"
then I will see that it will be produced:
" P>
Just use
grepl
:wire = c ("hello world "," Goodbye all "," Help is appreciated "," Hello Sam ") Wire [gripple ("hello", strings)] & lt; - "Mathematics" & gt; String [1] "Mathematics" "Goodbye All" "Help is appreciated" "Mathematics"
No comments:
Post a Comment