[R] word frequency count
David Winsemius
dwinsemius at comcast.net
Sun Mar 18 22:12:34 CET 2012
On Mar 18, 2012, at 3:07 PM, mail me wrote:
> Hi:
> Thanks for reply. I am using the following statement
>
> res <- with(df, table(paste(item1, item2, sep=', ')) )
>
> to get the frequency counts of the rows, which gives the following
> output:
> milk,bread 2
> bread,butter 1
> beer,diaper 3
> milk,bread 2
>
You have already been asked why we readers should think that
'milk,bread' has two different entries. Until that is resolved there
is not a firm basis for offering further assistance.
> But I need to extract from the above result two vectors or dataframes
> (such as DF1 and DF2) to make the final output as below:
>
> DF1
> milk,bread
> bread,butter
> beer,diaper
> milk,bread
>
> DF2
> 2
> 1
> 3
> 2
Nonetheless, if you want to ignore the obvious problems in your data
feel free to use this:
DF1 <- data.frame(V1 = res[ , 1])
DF2 <- data.frame(V1 = res[ , 2])
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list