Re: [R] Efficient way to use data frame of indices to initialize matrix

2010-12-08 Thread Cutler, Gene
Sent: Tuesday, December 07, 2010 11:00 AM > To: Greg Snow > Cc: Gene; r-help@r-project.org > Subject: Re: [R] Efficient way to use data frame of indices to > initialize matrix > > > On Dec 7, 2010, at 1:49 PM, Greg Snow wrote: > > > tmpdf <- data.frame( x = c(

Re: [R] Efficient way to use data frame of indices to initialize matrix

2010-12-07 Thread David Winsemius
eg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Cutler, Gene Sent: Tuesday, December 07, 2010 11:31 AM To: r-help@r-project.org Subjec

Re: [R] Efficient way to use data frame of indices to initialize matrix

2010-12-07 Thread Greg Snow
111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Cutler, Gene > Sent: Tuesday, December 07, 2010 11:31 AM > To: r-help@r-project.org > Subject: [R] Efficient way to use data frame of indices to initialize > mat

Re: [R] Efficient way to use data frame of indices to initialize matrix

2010-12-07 Thread Whit Armstrong
index m as a vector and do the assignment in one step i <- df$row + (df$col-1)*nrow(m) m[i] <- df$a or something along those lines. -Whit On Tue, Dec 7, 2010 at 1:31 PM, Cutler, Gene wrote: > I have a data frame with three columns, x, y, and a.  I want to create a > matrix from these values

[R] Efficient way to use data frame of indices to initialize matrix

2010-12-07 Thread Cutler, Gene
I have a data frame with three columns, x, y, and a. I want to create a matrix from these values such that for matrix m: m[x,y] == a Obviously, I can go row by row through the data frame and insert the value a at the correct x,y location in the matrix. I can make that slightly more efficient