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

Michael Dewey lists at dewey.myzen.co.uk
Fri Aug 28 17:16:09 CEST 2015


Dear Agrima

As well as Sarah's seven possibilities an eighth occurs to me: you have 
not yet read it into R in the first place. If that is the case you may 
be able to use read.table to get it into a data frame with columns 
corresponding to your words.
?read.table may be your friend here.

On 28/08/2015 15:42, Sarah Goslee wrote:
> 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
>
>

-- 
Michael
http://www.dewey.myzen.co.uk/home.html



More information about the R-help mailing list