I'm confused about the behavior of Hadley's "rbind.fill" function. I have a list of data frames I would like to do a simple rbind operation on, but the rbind.fill function is giving me results that I cannot explain. Note that the "rbind" function does give me the output I expect. Here is the minimal example:
library(reshape)
data1 <- structure(list(DATE = structure(c(1277859600, 1277856000), class = c("POSIXct",
"POSIXt"), tzone = "GMT"), BACK = c(0, -1)), .Names = c("DATE",
"BACK"), row.names = 1:2, class = "data.frame")
data2 <- structure(list(DATE = structure(c(1277856000, 1277852400), class = c("POSIXct",
"POSIXt"), tzone = "GMT"), BACK = c(0, -1)), .Names = c("DATE",
"BACK"), row.names = 1:2, class = "data.frame")
bind1 <- rbind.fill(list(data1, data2))
bind2 <- rbind(data1, data2)
data1
data2
bind1
bind2
DATE BACK
1 2010-06-30 01:00:00 0
2 2010-06-30 00:00:00 -1
DATE BACK
1 2010-06-30 00:00:00 0
2 2010-06-29 23:00:00 -1
DATE BACK
1 2010-06-29 18:00:00 0
2 2010-06-29 17:00:00 -1
3 2010-06-29 17:00:00 0
4 2010-06-29 16:00:00 -1
DATE BACK
1 2010-06-30 01:00:00 0
2 2010-06-30 00:00:00 -1
3 2010-06-30 00:00:00 0
4 2010-06-29 23:00:00 -1
So as you can see, bind1
which contains the rbind.fill
output creates new times in the DATE
column that were not even in the original dataset. Is this expected behavior? I am aware that I can simply use
bind <- do.call(rbind, list(data1, data2))
to bind the 5000 + dataframes I have, but can anyone speak to the aforementioned behavior?
Thank you.
Edit:
As @DWin pointed out below, this was not a problem with the rbind.fill function itself, but the fact that in the output the times were being printed in Pacific time, but were in GMT format.
SessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] tcltk grid stats graphics grDevices utils datasets methods
[9] base
other attached packages:
[1] tcltk2_1.1-5 reshape_0.8.4 plyr_1.4 proto_0.3-9.1
loaded via a namespace (and not attached):
[1] ggplot2_0.8.9 tools_2.12.1