[R] create a matrix with values from data.frame

From: Nicolas Gutierrez <nicolasg_at_uw.edu>
Date: Sat, 19 Mar 2011 14:29:57 -0700


Hello,

I'm trying to create a matrix (95x55) with data from a data.frame pop:

  xloc yloc      go  ind    Ene     totW
  1    23  20   516   1     0.02   20.21
  2    23  20  1143   1     0.02   20.21
  3    23  20   250   1     0.02   20.21
  4    22  15   251   1     0.02   18.69
  5    22  15   598   1     0.02   18.69
  6    21  19   250   1     0.02   20.21
  7    22  20   251   1     0.02   18.69
  8    22  20   598   1     0.02   18.69

where xloc is the x dimension, yloc the y dimension, and totW the values for each cell (xloc,yloc) in my matrix (55x95):

I'm trying:

Bio=with(pop, (table(factor(totW, levels = 1:55), factor(totW, levels = 1:95))))

But I don't get what I want. Hints? Thanks!

Nic



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 19 Mar 2011 - 21:39:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 19 Mar 2011 - 22:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive