Re: [R] Reducing execution time

2016-07-29 Thread sri vathsan
unction(d) paste( as.character(d), collapse= " ")) > #doc = paste(dat, collapse = " ## ") # just some arbitrary separator > character that isn't in your words > counts = sapply(words, function(w) length(grep(w, dat))) > names(counts) = words > counts > c

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
On Wed, Jul 27, 2016 at 11:19 PM, Sarah Goslee wrote: > You said you had 79 triplets and 8000 records. > > When I compared 100 triplets to 1 records it took 86 seconds. > > So obviously there is something you're not telling us about the format > of your data. > >

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
- combs[rep(1:nrow(combs), length=100), ] > > dat <- dat[rep(1:length(dat), length=1)] > > > > dim(combs) > [1] 100 3 > > length(dat) > [1] 1 > > > > system.time(test <- sapply(seq_len(nrow(combs)), > function(i)sum(sapply(dat, fu

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
Please re-read ?match *carefully* . > > Bert > > On Jul 27, 2016 6:15 AM, "sri vathsan" wrote: > > Hi, > > I created list of 3 combination numbers (mycombos, around 3 lakh > combinations) and counting the occurrence of those combination in another > list. Thi

[R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, I created list of 3 combination numbers (mycombos, around 3 lakh combinations) and counting the occurrence of those combination in another list. This comparision list (mylist) is having around 8000 records.I am using the following code. myCounts <- sapply(1:nrow(myCombos), FUN=function(i) {

Re: [R] frequency of items

2016-07-20 Thread sri vathsan
t;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

[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

Re: [R] Data reshaping with conditions

2016-04-20 Thread sri vathsan
tr)) { > svdatstr[row,"maxA"]<- > > max(svdatstr[row,count_ind[as.logical(match(svdatstr[1,type_ind],"A",0))]]) > svdatstr[row,"maxB"]<- > > max(svdatstr[row,count_ind[as.logical(match(svdatstr[1,type_ind],"B",0))]]) > svdatstr[row,

[R] Data reshaping with conditions

2016-04-20 Thread sri vathsan
Dear All, I am trying to reshape the data with some conditions. A small part of the data looks like below. Like this there will be more data with repeating ID. Count id name type 117 335 sally A 19 335 sally A 167 335 sally B 18 340 susan A 56 340 susan A 22 340 susan B 53 340 susan B 135 351 lee