t;))
>
>
>
>
>
> > Date: Fri, 8 Mar 2013 21:34:31 +0530
> > From: sudipanal...@gmail.com
> > To: r-help@r-project.org
> > Subject: [R] Word Frequency for each row
> >
> > Hi All,
> >
> > I am wond
013 21:34:31 +0530
> From: sudipanal...@gmail.com
> To: r-help@r-project.org
> Subject: [R] Word Frequency for each row
>
> Hi All,
>
> I am wondering if there is any examples where you can count your
> interested "word" in each row. For an example if you have data wi
; A.K.
>>
>>
>>
>> - Original Message -----
>> From: Rui Barradas
>> To: Sudip Chatterjee
>> Cc: r-help@r-project.org
>> Sent: Friday, March 8, 2013 4:26 PM
>> Subject: Re: [R] Word Frequency for each row
>>
>> Hello,
>>
>> flexible.
>>>
>>> Rui Barradas
>>>
>>> Em 08-03-2013 21:32, arun escreveu:
>>>
>>>
>>>
>>>> Hi,
>>>> You can also try:
>>>> res2<-rowSums(x==word)
>>>>
>>>> res1<-sapply(where,
as
To: Sudip Chatterjee
Cc: r-help@r-project.org
Sent: Friday, March 8, 2013 4:26 PM
Subject: Re: [R] Word Frequency for each row
Hello,
I'm not sure I understand, but see if the following is an example of
counting occurences of a word in each row.
set.seed(1855)
x <- matrix(sample(LET
as.numeric)
>> identical(res1,res2)
>>#[1] TRUE
>>A.K.
>>
>>
>>
>>- Original Message -
>>From: Rui Barradas
>>To: Sudip Chatterjee
>>Cc: r-help@r-project.org
>>Sent: Friday, March 8, 2013 4:26 PM
>>Subject: Re: [R] W
here,length)
res1[]<- sapply(res1,as.numeric)
identical(res1,res2)
#[1] TRUE
A.K.
- Original Message -
From: Rui Barradas
To: Sudip Chatterjee
Cc: r-help@r-project.org
Sent: Friday, March 8, 2013 4:26 PM
Subject: Re: [R] Word Frequency for each row
Hello,
I'm not sure I und
t: Re: [R] Word Frequency for each row
Hello,
I'm not sure I understand, but see if the following is an example of
counting occurences of a word in each row.
set.seed(1855)
x <- matrix(sample(LETTERS[1:5], 400, replace = TRUE), ncol = 4)
word <- "A"
where <- apply
This is even simpler
> aaa <- matrix(c("aa", "bb", "aa", "aa", "cc", "ee"), 2, 3,
dimnames=list(LETTERS[1:2], letters[3:5]))
> apply(aaa == "aa", 1, sum)
A B
2 1
On Fri, Mar 8, 2013 at 4:16 PM, Richard M. Heiberger wrote:
> > aaa <- matrix(c("aa", "bb", "aa", "aa", "cc", "ee"), 2, 3,
> dimnames
Hello,
I'm not sure I understand, but see if the following is an example of
counting occurences of a word in each row.
set.seed(1855)
x <- matrix(sample(LETTERS[1:5], 400, replace = TRUE), ncol = 4)
word <- "A"
where <- apply(x, 1, function(.x) grep(word, .x))
sapply(where, length) # count t
> aaa <- matrix(c("aa", "bb", "aa", "aa", "cc", "ee"), 2, 3,
dimnames=list(LETTERS[1:2], letters[3:5]))
> aaa
cde
A "aa" "aa" "cc"
B "bb" "aa" "ee"
> apply(aaa, 1, function(x, word) sum(x==word), word="aa")
A B
2 1
>
On Fri, Mar 8, 2013 at 11:04 AM, Sudip Chatterjee wrote:
> Hi All,
>
>
Hi All,
I am wondering if there is any examples where you can count your
interested "word" in each row. For an example if you have data with *'ID*'
and '*write-up*' for 100 rows, how would I calculate the word frequency for
each row ?
Thank you for all your time.
[[alternative HTML v
12 matches
Mail list logo