Re: [R] sum data from data.frame in a matrix

2011-02-23 Thread Dennis Murphy
0 . > 3 0 0 0 . > . > . > 10 0 81 0 > > 11 0 0 30 > 12 95 0 0 > > Any hints? > > THANKS!! > Nico > > > > Original Message > Subject:Re: [R] sum data from data.frame in a ma

Re: [R] sum data from data.frame in a matrix

2011-02-23 Thread Dennis Murphy
Hi: df <- read.table(textConnection(" + xloc yloc yield + 1 101295 + 2 111081 + 3 121120 + 4 121110"), header = TRUE) with(df, xtabs(yield ~ yloc + xloc)) xloc yloc 10 11 12 10 0 81 0 11 0 0 30 12 95 0 0 HTH, Dennis On Tue, Feb 22, 2011 at

[R] sum data from data.frame in a matrix

2011-02-22 Thread Nicolas Gutierrez
Hi all (again), I have a data frame "pop": xloc yloc yield 1 101295 2 111081 3 121120 4 121110 And I want to get the sum of yield for the cell (pop$xloc, pop$yloc) in a matrix as follows: xloc 10 11 12 10 0 81 0 yloc