[R] word frequency count

John Kane jrkrideau at inbox.com
Sun Mar 18 13:57:36 CET 2012


? table

First however confirm "that milk,bread" is a single datum. str() should do this

Can you post a sample of the data here using dput()?

John Kane
Kingston ON Canada


> -----Original Message-----
> From: mailme842 at googlemail.com
> Sent: Sun, 18 Mar 2012 13:12:48 +0200
> To: r-help at r-project.org
> Subject: [R] word frequency count
> 
> Hi:
> 
> I have a dataframe containing comma seperated group of words such as
> 
> milk,bread
> bread,butter
> beer,diaper
> beer,diaper
> milk,bread
> beer,diaper
> 
> I want to output the frequency of occurrence of comma separated words
> for each row and collapse duplicate rows, to make the output as shown
> in the following dataframe:
> 
> milk,bread   2
> bread,butter 1
> beer,diaper  3
> milk,bread   2
> 
> Thanks for help!
> 
> deb
> 
> ______________________________________________
> R-help at 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.

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!



More information about the R-help mailing list