I have a matrix (1000 x 224) that contains the output from the function boot.array. For each row, there are 224 columns that represent the case numbers of the selected individuals from a bootstrap. The cases are listed in selection order, not numerical order. I'd like to rearrange the cells so that every row has the column entries listed ascending numeric order. I've been able to do the sorting using two explicit for loops, but I cannot figure out a vectorized way to do it using apply, order, and/or sort. Is there a clever vectorized way to do this? Thanks. ====================Dr. Marc R. Feldesman Professor and Chairman Anthropology Department Portland State University 1721 SW Broadway Portland, Oregon 97201 email: feldesmanm at pdx.edu phone: 503-725-3081 fax: 503-725-3905 http://web.pdx.edu/~h1mf PGP Key Available On Request ===================== "Anyway, no drug, not even alcohol, causes the fundamental ills of society. If we're looking for the source of our troubles, we shouldn't test people for drugs, we should test them for stupidity, ignorance, greed and love of power." P.J. O'Rourke Powered by Optiplochoerus and Windows 2000 (scary isn't it?) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 2 Apr 2001, Marc Feldesman wrote:> I have a matrix (1000 x 224) that contains the output from the function > boot.array. For each row, there are 224 columns that represent the case > numbers of the selected individuals from a bootstrap. The cases are listed > in selection order, not numerical order. I'd like to rearrange the cells > so that every row has the column entries listed ascending numeric order. > > I've been able to do the sorting using two explicit for loops, but I cannot > figure out a vectorized way to do it using apply, order, and/or sort. Is > there a clever vectorized way to do this?Yes. Do a lexicographic sort on row then value, of the whole matrix as a vector. There's an example in S Programming p. 153 Simpler: A <- matrix(rnorm(1000*224), 1000, 224) A1 <- t(apply(A, 1, sort)) as compared to A2 <- t(matrix(A[order(row(A), A)], ,1000)) On my test the first was a little faster. E&OE, of course. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
A friend wants to fit the model of Zeger & Brookmeyer for censored autoregressions. Is there any package available with this capability? Murray Jorgensen -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._