You really need to spend some time learning R if you wish to use R. See ?grep and note the "value" argument. So you want:
whales.v <- grep(*^whal.*", moby.word.v,value = TRUE) -- Bert On Thu, Aug 3, 2017 at 5:14 AM, Riaan Van Der Walt <riaan.vanderw...@nwu.ac.za> wrote: > 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 > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.