Re: [R] frequency of items

2016-07-20 Thread sri vathsan
Hi all, I understand this is not a data frame but an individual variable from the data frame which is a list. Since, I need to work on this particular variable I just added here as a sample data. Jim, your code solved the purpose.Thanks! Regards, Srivathsan On Wed, Jul 20, 2016 at 4:29 PM, Ulr

Re: [R] frequency of items

2016-07-20 Thread Ulrik Stervbo
What you show cannot be a data.frame. Using what you gave, this should help you along: x <- c(11,15,12,25, 11,12, 15,25, 134,45,56, 46, 45,56, 15,12, 66,45,56,24,14,11,25,12,134) table(x) On Wed, 20 Jul 2016 at 11:44 Jim Lemon wrote: > Oops, didn't translate that function correctly: > > has_val

Re: [R] frequency of items

2016-07-20 Thread Jim Lemon
Oops, didn't translate that function correctly: has_values<-function(x,values) { if(is.list(x)) { return(sum(unlist(lapply(svlist, function(x,values) return(all(values %in% x)),values } } Jim On Wed, Jul 20, 2016 at 7:18 PM, Jim Lemon wrote: > Hi sri, > Maybe something like this? > >

Re: [R] frequency of items

2016-07-20 Thread Jim Lemon
Hi sri, Maybe something like this? has_values<-function(x,values) { if(is.list(x)) { return(sum(unlist(lapply(svlist, function(x,values) return(all(values %in% x)),c(11,12) } } svlist<-list(a=c(11,15,12,25), b=c(11,12), c=c(15,25), d=c(134,45,56), e=46, f=c(45,56), g=c(15,12), h

Re: [R] frequency of items

2016-07-20 Thread Michael Dewey
It seems very unlikely that what you quote can be a data frame. It could be a list I suppose. Can you clarify? On 19/07/2016 11:59, sri vathsan wrote: Hi, I have a data frame like below. 11,15,12,25 11,12 15,25 134,45,56 46 45,56 15,12 66,45,56,24,14,11,25,12,134 I want to identify the freque

[R] frequency of items

2016-07-19 Thread sri vathsan
Hi, I have a data frame like below. 11,15,12,25 11,12 15,25 134,45,56 46 45,56 15,12 66,45,56,24,14,11,25,12,134 I want to identify the frequency of pairs/triplets or higher that occurs in the data. Say for example, in above data the occurrence of pairs looks like below item No of occurrence