search for: indx

Displaying 20 results from an estimated 169 matches for "indx".

Did you mean: index
2011 Apr 06
5
Need a more efficient way to implement this type of logic in R
...ether the following logic. It works but is very slow. I'm sure that there must be a better r-specific way to implement this kind of thing, but have been unable to find/understand one. Any help would be appreciated. hh.sub <- households[c("HOUSEID","HHFAMINC")] for (indx in 1:length(hh.sub$HOUSEID)) { if ((hh.sub$HHFAMINC[indx] == '01') | (hh.sub$HHFAMINC[indx] == '02') | (hh.sub$HHFAMINC[indx] == '03') | (hh.sub$HHFAMINC[indx] == '04') | (hh.sub$HHFAMINC[indx] == '05')) hh.sub$CS_FAMINC[indx] <- 1 # Less than $2...
2012 Mar 16
3
Faster way to implement this search?
I am working on a simulation where I need to count the number of matches for an arbitrary pattern in a large sequence of binomial factors. My current code is for(indx in 1:(length(bin.05)-3)) if ((bin.05[indx] == test.pattern[1]) && (bin.05[indx+1] == test.pattern[2]) && (bin.05[indx+2] == test.pattern[3])) return.values$count.match.pattern[1] = return.values$count.match.pattern[1] + 1 Since I am running the above code for each...
2013 Mar 22
3
Distance calculation
Hi Elisa, I hope this is what you wanted. dat1<-read.csv("peaks.csv",sep=",") #Subset dat2<-dat1[1:5,] res1<-do.call(cbind,lapply(seq_len(nrow(dat2)),function(i) do.call(rbind,lapply(split(rbind(dat2[i,],dat2[-i,]),1:nrow(rbind(dat2[i,],dat2[-i,]))), function(x) {x1<-rbind(dat2[i,],x);
2006 May 26
2
combinatorial programming problem
...quot;symarray" for storing the results of functions symmetric in its k arguments. Intended use is for association indices for more than two variables, for instance coresistivity against antibiotics. There is one programming problem I haven't solved, making an inverse of the index function indx() --- se code below. It could for instance return the original k indexes in strictly increasing order, to make indx() formally invertible. Any ideas? Kjetil Code: # Implementing an S3 class for symarrays with array rank r for dimension # [k, k, ..., k] with k>=r repeated r times. We do n...
2012 Feb 21
2
Dataframes in PLS package
I have been working with the pls procedure and have problems getting the procedure to work with matrix or frame data. I suspect the problem lies in my understanding of frames, but can't find anything in the documentation that will help. Here is what I have done: I read in an 10000 x 8 table of data, and assign the first four columns to matrix A and the second four to matrix B pls <-
2014 Mar 24
4
[PATCH 1/4] pm/fan: drop the fan lock in fan_update() before rescheduling
From: Martin Peres <martin.peres at labri.fr> This should fix a deadlock that has been reported to us where fan_update() would hold the fan lock and try to grab the alarm_program_lock to reschedule an update. On an other CPU, the alarm_program_lock would have been taken before calling fan_update(), leading to a deadlock. We should Cc: <stable at vger.kernel.org> # 3.9+ Reported-by:
2010 Feb 22
1
shash in unique.c
...sense to hash the pointer itself rather than the string it points to? In other words could the SEXP pointer be cast to unsigned int and the usual scatter be called on that as if it were integer? shash would look like a slightly modified version of ihash like this : static int shash(SEXP x, int indx, HashData *d) { if (STRING_ELT(x,indx) == NA_STRING) return 0; return scatter((unsigned int) (STRING_ELT(x,indx), d); } rather than its current form which appears to hash the string it points to : static int shash(SEXP x, int indx, HashData *d) { unsigned int k; const char *p;...
2009 Sep 14
2
Escaping . in regular expression
If I run cvec<-c("test.f", "test.sf", "try.g","try.res", "try.f") print(cvec) indx<-grep('\.f',cvec,perl=TRUE) fset<-cvec[indx] print(fset) I get > cvec<-c("test.f", "test.sf", "try.g","try.res", "try.f") > print(cvec) [1] "test.f" "test.sf" "try.g" "try.res" &q...
2017 Oct 12
4
comparing two strings from data
...2017000071989 CTS2017000079931 CTS2017000072015 In a loop, when I use the following code to get those indices, data_2 = read.csv("excel_data.csv") column_1 = data_2$data1 column_2 = data_2$data2 match_list <- array(0,dim=c(310,1)); # 310 is the length of the first column for (indx in 1: 310){ for(indx2 in 1:713){ # 713 is the length of the second column if(column_1[indx] == column_2[indx2] ){ match_list[indx,1] = indx2; break; } } } R provides the following error: Error in Ops.factor(column_1[indx], column_2[indx2]) : leve...
2005 Sep 01
1
More block diagonal matrix construction code
...mlist<-list(...) ## handle case in which list of matrices is given if(length(mlist)==1)mlist<-unlist(mlist,rec=FALSE) csdim<-rbind(c(0,0),apply(sapply(mlist,dim),1,cumsum )) ret<-array(0,dim=csdim[length(mlist)+1,]) add1<-matrix(rep(1:0,2),nc=2) for(i in seq(along=mlist)){ indx<-apply(csdim[i:(i+1),]+add1,2,function(x)x[1]:x[2]) ## non-square matrix if(is.null(dim(indx)))ret[indx[[1]],indx[[2]]]<-mlist[[i]] ## square matrix else ret[indx[,1],indx[,2]]<-mlist[[i]] } ret } I doubt that there's any noticeable practical performance differ...
2013 Sep 26
1
Grouping Matrix by Columns; OHLC Data
HI, May be this helps: set.seed(24) ?mat1<- matrix(sample(1:60,30*24,replace=TRUE),ncol=24) colnames(mat1)<- rep(c("O","H","L","C"),6) indx<-seq_along(colnames(mat1)) n<- length(unique(colnames(mat1))) ?res<- lapply(split(indx,(indx-1)%%n+1),function(i) mat1[,i]) lapply(res,head,2) #$`1` #????? O? O? O? O? O? O #[1,] 18 56 51 24 24 52 #[2,] 14 31 60 12 43 34 # #$`2` #????? H? H? H? H? H? H #[1,] 20? 6? 4 23 10? 2 #[2,] 15 37 2...
2017 Aug 09
2
Package nleqslv ERROR
...))*((DEA)^(-GAMMA[1+k])))*((12^0.5)^(-GAMMA[1+k])))/((2-1*x[2])*(2^(-ALPHA[1+i]-GAMMA[1+k]))*((1*x[2]-1)^(-GAMMA[1+k]))*((((-1+1*x[2])^2)/2)^(-ALPHA[1+i]))))^(1/(1-2*ALPHA[1+i]-1.5*(GAMMA[1+k]))) f[4] <- 1*x[2] > 1 f } Result <- matrix(0,nrow=9*9*9,ncol=6) startx<-c(16350, 1.33) indx <- 1 for (i in 1:9) { for (j in 1:9) { for (k in 1:9) { f.startx <- fun(startx) if(anyNA(f.startx)) { Result[indx,1:3] <- NA } else { z <- nleqslv(startx,fun) Result[indx,1:3] <- c(z$termcd,z$x) } Result[indx,4:6] <- c(i,...
2013 Apr 14
1
possible loop problem
...ataset. Just from reading the data as is shown. dat1<- read.table(text=" separator,tissID >,>,2 ,2,1 ,6,5 ,11,13 >,>,4 ,4,9 ,6,2 ,7,3 ,21,1 ,23,58 ,25,9 ,26,4 >,>,11 ,1,12 >,>,21 ,4,1 ,11,3 ",sep=",",header=TRUE,stringsAsFactors=FALSE,row.names=NULL) indx<-which(grepl(">",dat1[,1])) indx1<-diff(c(indx,nrow(dat1)+1)) res1<-do.call(rbind,lapply(seq_along(indx),function(i) {x1<-dat1[indx[i]:(indx[i]+(indx1[i]-1)),];x1[-1,1]<- x1[1,3];x1})) res2<- as.matrix(res1[,-1]) row.names(res2)<- res1[,1] ?res2 #?? separator tis...
2002 Sep 01
2
rsync error: unexplained error
...Staples -------------------------------------------------------------------------------- Proposed new code in main.c #typedef struct int pid; int status; } pid_status; pid_status pid_stat_table[10]; static RETSIGTYPE sigchld_handler(int val) { #ifdef WNOHANG int indx int pid; int status; do { pid = waitpid(-1, &status, WNOHANG); for ( indx = 0; indx < 10; indx++ ) { if ( pid_stat_table[indx].pid == 0 ) { pid_stat_table[indx].pid = pid; pid_st...
2012 Mar 09
1
index values of one matrix to another of a different size
...1 "A" "D" "G" > row2 "B" "E" "H" > row3 "C" "F" "I" > > # this is a matrix of row references to vals above. The values all stay in > the same column but shift in row via the indices. > indx = matrix(c(1,1,3,3,2,2,2,3,1,2,2,1),nrow=4,ncol=3) > > indx > [,1] [,2] [,3] > [1,] 1 2 1 > [2,] 1 2 2 > [3,] 3 2 2 > [4,] 3 3 1 > ############### end sample data #################### > > # my solution > > > matrix(vals[cbin...
2006 Feb 25
2
Ruby Interface Recommendations Photo Gallery Creation?
Hi, I''m looking to create a gallery index page of thumbnail images which point to their associated images galleries. Also, I would like to organize the images from left to right and top to bottom. Furthermore, I would like to limit the number of thumbnail images on the page. I guess that I''m needing some type of horizontal looping interface for both the thumbnail index page
2013 Oct 11
3
matrix values linked to vector index
Hi, In the example you showed: m1<- matrix(0,length(vec),max(vec)) 1*!upper.tri(m1) #or ?m1[!upper.tri(m1)] <-? rep(rep(1,length(vec)),vec) #But, in a case like below, perhaps: vec1<- c(3,4,5) ?m2<- matrix(0,length(vec1),max(vec1)) ?indx <- cbind(rep(seq_along(vec1),vec1),unlist(tapply(vec1,list(vec1),FUN=seq),use.names=FALSE)) m2[indx]<- 1 ?m2 #???? [,1] [,2] [,3] [,4] [,5] #[1,]??? 1??? 1??? 1??? 0??? 0 #[2,]??? 1??? 1??? 1??? 1??? 0 #[3,]??? 1??? 1??? 1??? 1??? 1 A.K. Hi- I'd like to create a matrix of 0's...
2008 Aug 16
1
unique.default problem (PR#12551)
...owing line of code (produced by a mistake) caused an infinite loop unique("a",c("a","b")) or also unique(1,1:2) I made a little investigation, and it seems to be that the following function from unique.c is looping infinitely static int isDuplicated(SEXP x, int indx, HashData *d) { int i, *h; h = INTEGER(d->HashTable); i = d->hash(x, indx, d); while (h[i] != NIL) { if (d->equal(x, h[i], x, indx)) return h[i] >= 0 ? 1 : 0; i = (i + 1) % d->M; } h[i] = indx; return 0; } In this case h contains only one negati...
2012 Jul 30
3
replace values in vector from a replacement table
Dear all I've got stuck when trying to replace values in a vector by selecting replacements from a replacement table. I'm trying to use only base functions. Here's a dummy example: > (x <- rep(letters,2)) [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l"
2010 Sep 08
0
Correction to vec-subset speed patch
...t part -------------- Index: src/main/subset.c =================================================================== --- src/main/subset.c (revision 52822) +++ src/main/subset.c (working copy) @@ -59,73 +59,77 @@ if (x == R_NilValue) return x; - for (i = 0; i < n; i++) { - ii = INTEGER(indx)[i]; - if (ii != NA_INTEGER) - ii--; - switch (mode) { - case LGLSXP: - if (0 <= ii && ii < nx && ii != NA_LOGICAL) - LOGICAL(result)[i] = LOGICAL(x)[ii]; - else - LOGICAL(result)[i] = NA_INTEGER; - break; - case INTSXP: - if (0 <= ii && ii &lt...