[R] Reshaping data with xtabs giving me 'extra' data

2010-01-20 Thread Tony B
Dear all, Lets say I have several data frames as follows: set.seed(42) dates - as.Date(c(2010-01-19, 2010-01-20)) times - c(09:30:00, 11:30:00, 13:30:00, 15:30:00) shows - c(Red Dwarf, Being Human, Doctor Who) df1 - data.frame(Date = dates[1], Time = times[1], Show = shows, Score = 1:3)

Re: [R] Reshaping data with xtabs giving me 'extra' data

2010-01-20 Thread Henrique Dallazuanna
Try with tapply: with(do.call(rbind, df.list), tapply(Score, list(Date, Time, Show), length)) On Wed, Jan 20, 2010 at 10:20 AM, Tony B tony.bre...@googlemail.com wrote: Dear all, Lets say I have several data frames as follows: set.seed(42) dates - as.Date(c(2010-01-19, 2010-01-20)) times

Re: [R] Reshaping data with xtabs giving me 'extra' data

2010-01-20 Thread Tony B
Thank you for taking the time to reply Henrique. Although your solution does take away the zeroes and replaces them with NA's (which i prefer), it unfortunately seems to reduce all of the other scores to just '1': x - with(do.call(rbind, df.list), tapply(Score, list(Date, Show, Time), length))

Re: [R] Reshaping data with xtabs giving me 'extra' data

2010-01-20 Thread Henrique Dallazuanna
You can use this instead: with(do.call(rbind, df.list), tapply(Score, list(Date, Show, Time), invisible)) On Wed, Jan 20, 2010 at 3:02 PM, Tony B tony.bre...@googlemail.com wrote: Thank you for taking the time to reply Henrique. Although your solution does take away the zeroes and replaces