[R] Frequency count of terms only in a given column in R

Sarah Goslee sarah.goslee at gmail.com
Fri Aug 28 16:42:25 CEST 2015


Hi,

On Fri, Aug 28, 2015 at 7:49 AM, agrima seth <sethagrima at gmail.com> wrote:
> i have a text file with data of the given format:
>
> white snow
> lived snow
> in snow
> lived place
> in place
> a place
> called place
> as place

That doesn't specify the format. I can think of at least seven things
that could be:
a character vector
a two-column matrix
a one-column matrix
a two-column data frame, with or without values correctly specified as character
a one-column data frame, with or without values correctly specified as character

The correct answer depends on what the format actually is; you need to
use dput() or some other unambiguous way of providing sample data.

Here are some suggestions for creating a good reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Some combination of strsplit() and table(), possibly with apply(),
will be the answer, though.

Sarah

> here i have to find the frequency of the terms only in the first column
> (i.e.)
> white - 1
> lived- 2
> in -2
> a-1
> called - 1
> as -1
>
> Could you please guide me how to do the above in R.
>
>         [[alternative HTML version deleted]]
and please don't post in HTML, as it makes figuring out what you meant
even more difficult.

Sarah


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list