Skip to content
Prev 206926 / 398503 Next

Reshaping data with xtabs giving me 'extra' data

Dear all,

Lets say I have several data frames as follows:
Date     Time        Show Score
1 2010-01-20 15:30:00   Red Dwarf     1
2 2010-01-20 15:30:00 Being Human     2
3 2010-01-20 15:30:00  Doctor Who     3

I would like to somehow reshape the data into a different format:
This is where my problem occurs. In Time = 13:30:00, there is now data
for "2010-01-19" which was not in any of my original data frames
above:
Show
Date         Being Human Doctor Who Red Dwarf
  2010-01-19           0          0         0
  2010-01-20           2          3         1

Perhaps I am missing something in the way i call the xtabs function?

Thank you kindly for your time,
Tony Breyal

OS: Windows XP 64bit
R version 2.10.0 (2009-10-26)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252    LC_MONETARY=English_United States.1252
LC_NUMERIC=C                           LC_TIME=English_United States.
1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods
base

loaded via a namespace (and not attached):
[1] tools_2.10.0