Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timezones are lost sometimes, when using bind_rows #2322

Closed
pchtsp opened this issue Dec 14, 2016 · 1 comment
Closed

timezones are lost sometimes, when using bind_rows #2322

pchtsp opened this issue Dec 14, 2016 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@pchtsp
Copy link

pchtsp commented Dec 14, 2016

I'm pretty sure this started happening since I recently updated dplyr.
I use as.POSIXct to transform characters into datetime objects. It automatically assigns the timezone for the current timezone of the PC (in my case "Europe/Paris"). In some cases I enforce the timezone (with the argument tz=Sys.timezone()). In my pc, this last function returns "Europe/Paris".

Apparently, there is an issue when binding rows with two dataframes, where one has been manually assigned a timezone and the other has an automatic one, although I've checked they both show CET as timezone. Not sure if this is the only issue I had with dates.

The first case shows "2016-01-01 UTC" "2016-01-01 UTC". The rest show correctly "2016-01-01 01:00:00 CET" "2016-01-01 01:00:00 CET"
If I enforce both or I enforce non, it works ok.
If I try with rbindlist or rbind, the first case works ok.

library(dplyr)
library(magrittr)
library(data.table)

bind_rows(
  data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00", tz= Sys.timezone()))
  ,data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00"))
  ) %>% use_series(b)

bind_rows(
  data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00", tz= Sys.timezone()))
  ,data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00", tz= Sys.timezone()))
) %>% use_series(b)

bind_rows(
  data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00"))
  ,data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00"))
) %>% use_series(b)

rbindlist(list(
  data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00", tz= Sys.timezone()))
  ,data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00"))
)) %>% use_series(b)

rbind(
  data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00", tz= Sys.timezone()))
  ,data.frame(a= 4, b= as.POSIXct("2016-01-01 01:00"))
) %>% use_series(b)

More info:

R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252   
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C                  
[5] LC_TIME=Spanish_Spain.1252    

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

other attached packages:
[1] data.table_1.10.0 magrittr_1.5      dplyr_0.5.0      

loaded via a namespace (and not attached):
[1] R6_2.1.2        assertthat_0.1  rsconnect_0.4.3 DBI_0.5-1       tools_3.3.1    
[6] tibble_1.1      Rcpp_0.12.5  
@krlmlr krlmlr added bug an unexpected problem or unintended behavior data frame labels Dec 15, 2016
@krlmlr
Copy link
Member

krlmlr commented Dec 15, 2016

Thanks, confirmed.

@hadley hadley closed this as completed Feb 20, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants