Re: [R] Reshaping grouped data

2010-02-16 Thread Peter Dalgaard
Whoops, forgot to cc. the list... -pd Myrland Øystein wrote: > Dear R-help list, > > > > I have grouped data, looking like this: > > > > cases <- c(23,12,56,81) > > total <- c(123,234,248,390) > > x1 <- c(0,0,1,1) > > x2 <- c(0,1,0,1) > > > > Data <- as.data.frame(cbind(cases,total

Re: [R] Reshaping grouped data

2010-02-16 Thread Dimitris Rizopoulos
one approach is: Data.long <- with(Data, data.frame( w = c(rbind(total - cases, cases)), y = rep(0:1, nrow(Data)), x1 = rep(x1, each = 2), x2 = rep(x2, each = 2) )) I hope it helps. Best, Dimitris Myrland Øystein wrote: Dear R-help list, I have grouped data, looking lik

[R] Reshaping grouped data

2010-02-16 Thread Myrland Øystein
Dear R-help list, I have grouped data, looking like this: cases <- c(23,12,56,81) total <- c(123,234,248,390) x1 <- c(0,0,1,1) x2 <- c(0,1,0,1) Data <- as.data.frame(cbind(cases,total,x1,x2)) Data I would like to run a logistic regression with group weights on these, where cases