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

mutate errors when coercing to POSIXlt types #670

Closed
jimhester opened this issue Oct 8, 2014 · 4 comments
Closed

mutate errors when coercing to POSIXlt types #670

jimhester opened this issue Oct 8, 2014 · 4 comments
Assignees
Milestone

Comments

@jimhester
Copy link
Contributor

It happens if you use as.POSIXlt() or strptime() directly.

data.frame(time='2014/01/01 10:10:10') %>% dplyr::mutate(time=as.POSIXlt(time))
# Error: wrong result size (11), expected 1 or 1

You get the same error wrong result size (11) regardless of the length of the data.frame
The expected output would be the same as using plyr::mutate()

str(data.frame(time='2014/01/01 10:10:10') %>% plyr::mutate(time=as.POSIXlt(time)))
# 'data.frame': 1 obs. of  1 variable:
#  $ time: POSIXlt, format: "2014-01-01 10:10:10"

This error occurs in both dplyr version 0.3.0.1 on CRAN and latest github versions.

Session Info:

Session info------------------------------------------
 setting  value
 version  R version 3.1.1 (2014-07-10)
 system   x86_64, darwin13.3.0
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 tz       America/New_York

Packages---------------------------------------------
 package    * version    date       source
 assertthat   0.1        2013-12-06 CRAN (R 3.1.1)
 colorspace   1.2.4      2013-09-30 CRAN (R 3.1.1)
 crayon       1.0.0      2014-09-28 Github (gaborcsardi/crayon@be81a40)
 DBI          0.3.0      2014-09-03 CRAN (R 3.1.1)
 devtools   * 1.6.0.9000 2014-09-25 Github (hadley/devtools@51ebc3a)
 digest       0.6.4      2013-12-03 CRAN (R 3.1.1)
 dplyr      * 0.3.0.9000 2014-10-08 Github (hadley/dplyr@87ffc2d)
 evaluate     0.5.5      2014-04-29 CRAN (R 3.1.1)
 formatR      1.0        2014-08-25 CRAN (R 3.1.1)
 ggplot2    * 1.0.0      2014-05-21 CRAN (R 3.1.1)
 gtable       0.1.2      2012-12-05 CRAN (R 3.1.1)
 htmltools    0.2.6      2014-09-08 CRAN (R 3.1.1)
 httr         0.5        2014-09-02 CRAN (R 3.1.1)
 knitr        1.6.21     2014-10-07 Github (yihui/knitr@513d68f)
 lazyeval     0.1.9      2014-10-03 Github (hadley/lazyeval@6dcbee9)
 magrittr     1.0.1      2014-05-15 CRAN (R 3.1.1)
 MASS         7.3.33     2014-05-05 CRAN (R 3.1.1)
 munsell      0.4.2      2013-07-11 CRAN (R 3.1.1)
 plyr         1.8.1      2014-02-26 CRAN (R 3.1.1)
 proto        0.3.10     2012-12-22 CRAN (R 3.1.1)
 R6           2.0        2014-08-19 CRAN (R 3.1.1)
 Rcpp         0.11.3     2014-09-29 CRAN (R 3.1.1)
 RCurl        1.95.4.3   2014-07-29 CRAN (R 3.1.1)
 reshape2     1.4        2014-04-23 CRAN (R 3.1.1)
 rex        * 0.1.0      <NA>       local
 rmarkdown    0.3.3      2014-09-17 CRAN (R 3.1.1)
 roxygen2     4.0.2.9000 2014-10-01 Github (klutometis/roxygen@78d5d7b)
 rstudioapi   0.1        2014-03-27 CRAN (R 3.1.1)
 scales       0.2.4      2014-04-22 CRAN (R 3.1.1)
 setwidth   * 1.0.3      2013-01-16 CRAN (R 3.1.1)
 stringr      0.6.2      2012-12-06 CRAN (R 3.1.1)
 testthat   * 0.9.0.9000 2014-09-28 Github (hadley/testthat@1e64e0c)
 vimcom     * 1.0.0      2014-09-18 Github (jalvesaq/VimCom@70fec5c)
 yaml         2.1.13     2014-06-12 CRAN (R 3.1.1)
@hadley
Copy link
Member

hadley commented Oct 8, 2014

I don't think we can support POSIXlt in data frames - it really is a list of 11 components. You're much better off with POSIXct.

@romainfrancois
Copy link
Member

We could, with some work. I think what I'm going to do is use POSIXlt as an advanced example for #650 if it still does make sense when I tackle it.

@jimhester
Copy link
Contributor Author

Fair enough, I didn't realize how POSIXlt was implemented. POSIXct works fine for my use case as well.

@romainfrancois
Copy link
Member

I've made this explicit:

> data.frame(time='2014/01/01 10:10:10') %>% dplyr::mutate(time=as.POSIXlt(time))
Erreur : `mutate` does not support `POSIXlt` results

Perhaps not as good as actually supporting POSIXlt, but less it'd be more work.

@romainfrancois romainfrancois added this to the 0.3.1 milestone Oct 13, 2014
@romainfrancois romainfrancois self-assigned this Oct 13, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 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