Dear Jim, Thanks for your suggestion. I have a follow-up question for fellow R Users that have followed this thread:
*I used to create two lists by some very flexible criteria to compare from "iData" and pass the two lists to *ANOTHER FUNCTION* that further decompose the two lists and do some case by case analysis: comp.lst[[1]] <- subset(iData,(Session==1 & TrialList==2 & BadTrial==0 & Correct==1 & Critical.BT>0)) comp.lst[[2]] <- subset(iData,(Session==2 & TrialList==2 & BadTrial==0 & Correct==1 & Critical.BT>0)) *The function will then do some subject by subject processing: tmplist <- comp.lst[[1]] subject <- unique(tmplist$Subject) Psubjmatrix <- NULL for(j in 1:length(subj)) { ##divide the list and process per subject in the list subjtriallist <- subset(tmplist,(Subject==subj[j])) ##divide the list and process per subject in the list print(paste("Start working on Subject ",subj[j],sep=""),quote=FALSE) ##The sub-divided list is passed to another function to extract data from corresponding object Ptrialmatrix <- SeekObject(subjtriallist,seconds,samplesize,sdmax); ##add rowmean to subject pupil matrix Psubjmatrix <- cbind(Psubjmatrix, rowMeans(Ptrialmatrix, na.rm=TRUE, dims=1)) } *But now, I have a pre-processed the objects and cooked up a 1500x20000 matrix, and there is no need to get these objects one by one for extraction, I may just do the following: Ptrialmatrix <- PMasterMatrix[subjindex,,drop=FALSE] *However, on passing the index to the function, I cannot further sub-divide the list index by Subject. I have been thinking of passing the criteria to within the function. But... what smarter thing I can do to make it works? - John On Thu, May 21, 2009 at 10:33 AM, jim holtman <jholt...@gmail.com> wrote: > Assuming that you get the list of indices into iData for the criteria, then > you can use that to get the appropriate rows: > > indx <- which(iData >5) # or whatever your criteria is > DataSeq[indx,, drop=FALSE] # gives you a subset matrix of just the rows you > are interested in. > > On Thu, May 21, 2009 at 10:10 AM, tsunhin wong <thjw...@gmail.com> wrote: >> >> Dear R Users, >> >> I have created a 1500 x 20000 data frame - DataSeq. Each of the 1500 >> rows represents a data sequence. >> I have another data frame iData that stores the information of these >> 1500 data sequences in the same order, for example, condition, gender, >> etc. >> >> If I use "subset" to select certain groups within iData according to >> some criteria that I have set, e.g. condition, gender >> Then how can I used the retrieved subset of iData to point to and >> retrieve corresponding rows in the DataSeq data.frame for >> manipulations and analysis? >> >> I hope some of you can give me some idea! >> Thank you very much!!! >> >> - John >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem that you are trying to solve? > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.