Dear,
Many bright people here!
I wrote:
Siem> dear S-Plus users, What do I wrong? I try to fill a sparse
Siem> matrix. Suppose I have a (large) matrix n*k X and data resid
Siem> unequal zero of length m. I also have row.num and col.num
Siem> both of length m indicating each element of which row and
Siem> collumn corresponds with a value of resid. I thought to be
Siem> clever, using the assignment :
Siem> X[row.num, col.num]<-resid[1:m]
I counted more than 14 answers (stopped counting..) all giving the
similar answer (some with empirical evidence) :
Try this:
X[cbind(row.num, col.num)] <- resid[1:m]
Thanks!
Dr. S.H. Heisterkamp
University of Amsterdam
Department of Clinical Epidemiology and Biostatistics
room J2-220
PO Box 22700 1100 DE Amsterdam
tel: +31-(0)-20-5668520
fax:+31-(0)-20-6912683
s.h.heisterkamp@amc.uva.nl
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|