Re: [R] Word Frequency for each row

2013-03-09 Thread Tyler Rinker
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

Re: [R] Word Frequency for each row

2013-03-09 Thread Tyler Rinker
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

Re: [R] Word Frequency for each row

2013-03-09 Thread Sudip Chatterjee
; 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, >>

Re: [R] Word Frequency for each row

2013-03-09 Thread Sudip Chatterjee
>> flexible. >>> >>> Rui Barradas >>> >>> Em 08-03-2013 21:32, arun escreveu: >>> >>> >>> >>>> Hi, >>>> You can also try: >>>> res2<-rowSums(x==word) >>>> >>>> res1<-sapply(where,

Re: [R] Word Frequency for each row

2013-03-09 Thread Rui Barradas
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

Re: [R] Word Frequency for each row

2013-03-09 Thread arun
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

Re: [R] Word Frequency for each row

2013-03-08 Thread Rui Barradas
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

Re: [R] Word Frequency for each row

2013-03-08 Thread arun
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

Re: [R] Word Frequency for each row

2013-03-08 Thread Richard M. Heiberger
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

Re: [R] Word Frequency for each row

2013-03-08 Thread Rui Barradas
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

Re: [R] Word Frequency for each row

2013-03-08 Thread Richard M. Heiberger
> 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, > >

[R] Word Frequency for each row

2013-03-08 Thread Sudip Chatterjee
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