I have a vector of strings in R studio:
c(“apple”,”chicken”, “banana”, “cherry”, “coffee”)
Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: I have a vector of strings in R studio:…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Now I want to identify all the words that contain an “a” in this vector and put these words into another vector. How can I do that in R studio? My original vector contains thousands of strings so I can’t just go manually through it.
Expert Answer
Code :
x <- c(“apple”,”chicken”, “banana”, “cherry”, “coffee”)
Index = grep(“a”, x);
x[Index]
Result :