[R] Identifying words ending with anything, say "ing"

Charlie F cfriedem at gmail.com
Wed May 30 16:28:18 CEST 2012


#sample words
words <- c("fixing","Dog","Carting","kite","running","playing")

#find words ending in 'ing'
result <- regexpr("^[a-zA-Z]+ing$",words)
result
[1]  1 -1  1 -1  1  1
attr(,"match.length")
[1]  6 -1  7 -1  7  7
attr(,"useBytes")
[1] TRUE

# you can use result to take out the offending words:
new.words <- words[-which(result>0)]
new.words
[1] "Dog"  "kite"

Hope that helps.


aksay1210 wrote
> 
> Can i know how to identify words ending with "ing", say
> "playing","praying","remembering" etc. 
> I want to remove such words using removeWords function.
> 

--
View this message in context: http://r.789695.n4.nabble.com/Identifying-words-ending-with-anything-say-ing-tp4631834p4631835.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list