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

Subset with time changes timezone #221

Closed
eibanez opened this issue Jan 27, 2014 · 1 comment
Closed

Subset with time changes timezone #221

eibanez opened this issue Jan 27, 2014 · 1 comment
Assignees

Comments

@eibanez
Copy link
Contributor

eibanez commented Jan 27, 2014

I have found a strange behavior when using subset with dates. As you can see, the timezone in the datetime column changes. Winston also found this behavior on a Mac (https://groups.google.com/forum/#!topic/manipulatr/p39QNVQ8bUg).

I have not checked if the other verbs have a similar impact. Here is a small example, the results and my session info.

CODE

library(dplyr)
library(lubridate)

date.start <- ymd_hms("2014-01-01 00:00:00")
test <- data.frame(Date = date.start + hours(1:10))
test2 <- test %.% filter(Date < date.start + hours(5))

RESULTS

> test$Date[1:5]
[1] "2014-01-01 01:00:00 UTC" "2014-01-01 02:00:00 UTC" "2014-01-01 03:00:00 UTC"
[4] "2014-01-01 04:00:00 UTC" "2014-01-01 05:00:00 UTC"

> test2$Date[1:4]
[1] "2013-12-31 18:00:00 MST" "2013-12-31 19:00:00 MST" "2013-12-31 20:00:00 MST"
[4] "2013-12-31 21:00:00 MST"

SESSION INFO

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: i386-w64-mingw32/i386 (32-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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.3.1 dplyr_0.1      

loaded via a namespace (and not attached):
[1] assertthat_0.1 digest_0.6.4   memoise_0.1    plyr_1.8       Rcpp_0.10.6   
[6] stringr_0.6.2  tools_3.0.2
@hadley
Copy link
Member

hadley commented Jan 27, 2014

@romainfrancois I think this just means that you're not copying the tz attribute. In the case of grouped mutate or summary, the individual groups should return vectors which all have the same tz attribute, but it is possible that they might be different. In that case, I think the best thing you can do is issue a warning.

@ghost ghost assigned romainfrancois Jan 27, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jun 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants