Hi all, I want to cout the different words in a text. You see if the text is: "hola mundo mundo" the program will count: hola 1 mundo 2 Is posible that Cran r have a similar function? [[alternative HTML version deleted]]
> x <- c("hola mundo mundo");> table(unlist(strsplit(x, " "))) hola mundo 1 2 > Is this what you are looking for? I hope this helps. Chel Hee Lee On 1/22/2015 8:25 AM, bgnumis bgnum wrote:> Hi all, > > I want to cout the different words in a text. > > You see if the text is: "hola mundo mundo" the program will count: > > hola 1 > mundo 2 > > Is posible that Cran r have a similar function? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
table(strsplit("hola mundo mundo", " ")[[1]]) On Thu, Jan 22, 2015 at 9:25 AM, bgnumis bgnum <bgnumis at gmail.com> wrote:> Hi all, > > I want to cout the different words in a text. > > You see if the text is: "hola mundo mundo" the program will count: > > hola 1 > mundo 2 > > Is posible that Cran r have a similar function? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
That' s perfect. Many thanks forma your appreciated help. El 22/01/2015 19:50, "Chel Hee Lee" <chl948 at mail.usask.ca> escribi?:> > x <- c("hola mundo mundo"); > > table(unlist(strsplit(x, " "))) > > hola mundo > 1 2 > > > > Is this what you are looking for? I hope this helps. > > Chel Hee Lee > > On 1/22/2015 8:25 AM, bgnumis bgnum wrote: > >> Hi all, >> >> I want to cout the different words in a text. >> >> You see if the text is: "hola mundo mundo" the program will count: >> >> hola 1 >> mundo 2 >> >> Is posible that Cran r have a similar function? >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at 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. >> >>[[alternative HTML version deleted]]
In addition to the other suggestions, which are fine for your simple example, I would take a trip to the CRAN Task View "Natural Language Processing", and see if there's anything there. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 1/22/15, 6:25 AM, "bgnumis bgnum" <bgnumis at gmail.com> wrote:>Hi all, > >I want to cout the different words in a text. > >You see if the text is: "hola mundo mundo" the program will count: > >hola 1 >mundo 2 > >Is posible that Cran r have a similar function? > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at 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.