Re: [R] conditionally sum

2010-08-28 Thread RICHARD M. HEIBERGER
See ?table for details. > tmp <- ' yx + 1 1 2008 + 2 1 2008 + 3 0 2008 + 4 0 2009 + 5 1 2009' > data <- read.table(textConnection(tmp), header=TRUE) > data yx 1 1 2008 2 1 2008 3 0 2008 4 0 2009 5 1 2009 > table(data$x, data$y) 0 1 2008 1 2 20

[R] conditionally sum

2010-08-28 Thread André de Boer
Hi, Suppose I have a dataframe like: > data yx 1 1 2008 2 1 2008 3 0 2008 4 0 2009 5 1 2009 Now I want to know how much "1" corresponds with 2008 and how much with 2009, the answers are 3 and 1. How can I achieve this? Thanks for the anwer. André [[al