[R] Efficient way to fill a matrix

Philipp Pagel p.pagel at wzw.tum.de
Fri Nov 7 09:27:04 CET 2008


	Thank you Phil and Bert!

I was sure there must be an efficient way using some kind of
indexing trick but totally did not see the as.matrix solution.

Thanks again
	Philipp


On Wed, Nov 05, 2008 at 02:59:20PM -0800, Phil Spector wrote:
> Philipp -
>
>    res = matrix(NA,5,3)
>    res[as.matrix(foo[,c(1,2)])] = foo$val
>


-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel



More information about the R-help mailing list