- 1. matrix manipulation question (score: 1)
- Author: Jordão, Felipe <Felipe.Jordao@moodys.com
- Date: Wed, 20 Jul 2005 11:16:07 -0400
- Hi all, I have a matrix with some numbers (0:5). The number sequence usually begins with 1, but if starts in column 1 it can begin with another number. Once started it will go sequentially with no 0s
- /archives/html/s-news/2005-07/msg00110.html (9,124 bytes)
- 2. Re: matrix manipulation question (score: 1)
- Author: David L Lorenz <lorenz@usgs.gov>
- Date: Wed, 20 Jul 2005 11:02:36 -0500
- Use apply instead of a for loop. Here's an example of a function that should work. Note that apply returns a matrix that would need to be transposed. apply(matrix(c( 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- /archives/html/s-news/2005-07/msg00111.html (11,930 bytes)
- 3. Re: matrix manipulation question (score: 1)
- Author: jsv@stat.ohio-state.edu
- Date: Wed, 20 Jul 2005 12:21:08 -0400 (EDT)
- The only problem is if there is more than one "1" in a row: Here's the same idea, with the fix: leadin1 <- function(mat=start.matrix){ nr <- nrow(mat) nc <- ncol(mat) pat <- rep(c(1,0),nr) terminals
- /archives/html/s-news/2005-07/msg00112.html (12,919 bytes)
- 4. Re: matrix manipulation question (score: 1)
- Author: sbackwards@comcast.net (SD Chasalow)
- Date: Wed, 20 Jul 2005 17:48:03 +0000
- You don't need the apply call either. Here's a version without it. With only 30 rows, the apply is just fine; actually a tad faster than my version. If you were doing this thing on a 10,000 x 30 matr
- /archives/html/s-news/2005-07/msg00113.html (14,419 bytes)
This search system is powered by
Namazu