[R] find similar words in text

Riaan Van Der Walt Riaan.VanDerWalt at nwu.ac.za
Thu Aug 3 14:14:02 CEST 2017


I received this from Matt Jockers and it worked!
I missed something.
How can I now see(display) this list?
Hi Riann, 

There are a couple of ways that you could do this. . . the best
approach would probably be to use *grep* instead of *which*, but let me
show you both ways.

On page 30, replace
whales.v <- which(moby.word.v == *whale*) 
with 
whale_words <- c(*whale", *whales", *whale's", *whaler", *whalers",
*whaling")
whales.v <- which(moby.word.v %in% whale_words) 

the alternative (better) way to do this, with grep, looks like this

whales.v <- grep(*^whal.*", moby.word.v) 

grep uses the regular expression ^whal.* to find all words starting (^)
with *whal* followed by any number of other characters (.*)

All best,

Matt

--
Matthew L. Jockers
Associate Dean for Research and Partnerships
College of Arts & Sciences
Susan J. Rosowski Associate Professor of English
University of Nebraska-Lincoln
1223 Oldfather Hall
P.O. Box 880312
Lincoln, NE  68588-0312
402.472.2891
www.matthewjockers.net
 
I am new to R.
Busy with Text Analysis.
 
Need a script to find e.g 
 
whale, whales, whale's, whaler, whalers, whaling,... in Moby Dick
 
Riaan


More information about the R-help mailing list