Re: [R] Counting Words
That' s perfect. Many thanks forma your appreciated help. El 22/01/2015 19:50, "Chel Hee Lee" 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@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]] __ 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.
Re: [R] Counting Words
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" 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@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.
Re: [R] Counting Words
table(strsplit("hola mundo mundo", " ")[[1]]) On Thu, Jan 22, 2015 at 9: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@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.
Re: [R] Counting Words
> 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@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.
[R] Counting Words
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@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.
Re: [R] counting words that are contained in a list
Hi, May be this helps: vec1 <- c("victory","happiness","medal","war","service","ribbon", "dates") vec2 <- c("The World War II Victory Medal was first issued as a service ribbon referred to as the Victory Ribbon.", "By 1946, a full medal had been established which was referred to as the World War II Victory Medal.", "The medal commemorates military service during World War II and is awarded to any member of the United States military, including members of the armed forces of the Government of the Philippine Islands, who served on active duty, or as a reservist, between December 7, 1941 and December 31, 1946","This is awarded for service between 7 December 1941 and 31 December 1946, both dates inclusive") res <- sort(table(factor(unlist(regmatches(tolower(vec2),gregexpr(paste(vec1,collapse="|"),vec2,ignore.case=TRUE))),levels=vec1)),decreasing=TRUE) res # war medal victory service ribbon dates happiness # 5 4 3 3 2 1 0 res[1:5] A.K. Hi guys! I have a vector with a list of words e.g c("victory","happines"). I have a vector of sentence e.g. In "WWII the victory was achived by allied forces". As word victory is in my list, victory has a frequency of 1, happines 0. At the end I wolud like to get 5 most frequent words from my list that appear in sentences. Can you help me. Uros __ R-help@r-project.org mailing list 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.