| To: | <s-news@lists.biostat.wustl.edu> |
|---|---|
| Subject: | Extracting Elements from a matrix |
| From: | "Ilouga, Pierre" <Pierre.Ilouga@evotec.com> |
| Date: | Wed, 7 Nov 2007 18:11:36 +0100 |
| Thread-index: | AcghYUBt53Q3oqr2RyWEATzTh8bRug== |
| Thread-topic: | Extracting Elements from a matrix |
|
Dear Splus experts, Does anyone has an idea how to extract some elements from a matrix in an EFFICIENT way? The following example clarifies my question. Given a 5x3 matrix mat <- matrix(1:15, nrow=5, byrow=F) and a length 5 -vector of positions pos <- c(2, 1, 3, 3, 1), the goal is to extract the vector c(6, 2, 13, 14, 5) which corresponds to the column pos[j] (j in 1:3) and row i ( i in 1:5) without using for-loops and other memory consuming functions. I’ve solve it via lists. However the slowness of the command executions doesn’t make it useful for monte carlo simulation. Thanks in advance. PI S-PLUS : Copyright (c) 1988, 2002 Insightful Corp. S : Copyright Lucent Technologies, Inc. Version 6.1.2 Release 2 for Linux 2.2.12 : 2002 Working data will be in .Data Screening Operations/Discovery Informatics EVOTEC AG Schnackenburgallee 114 22525 Hamburg Germany pierre.ilouga@evotec.com www.evotec.com
Evotec AG Hamburg. Amtsgericht Hamburg HRB 68223 |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Simple recode problem, Chuck Cleland |
|---|---|
| Next by Date: | Re: Extracting Elements from a matrix, Richard A. Becker |
| Previous by Thread: | Questions about SsfFit, Bernardo Ribeiro |
| Next by Thread: | Re: Extracting Elements from a matrix, Biggerstaff, Brad J. \(CDC/CCID/NCZVED\) |
| Indexes: | [Date] [Thread] [Top] [All Lists] |