Skip to content

Problem with Date format #194

@manuelreif

Description

@manuelreif

Hi!
Thank you for developing the dplyr package!
I used the package for the very first time and I had some issues with date vectors. I browsed the issues but haven´t found a solution for the problem.
Here is what happens if I want to use summarise() in order to get the 'earliest' observation from my data.frame.

library(dplyr)
# seed
set.seed(111)
# create variables
ID     <- rep(letters[1:4],each=5)
date   <-  ymd(paste0(sample(c(1960:2014),length(ID),replace=TRUE),sample(sprintf(fmt="%02d",1:12),length(ID),replace=TRUE),sample(sprintf(fmt="%02d",1:25),length(ID),replace=TRUE)))
number <-  rnorm(length(ID))
# create data.frame
d <- data.frame(ID,date,number)
# use dplyr
d_dplyr <- tbl_df(d)
d_dplyr %.% group_by(ID) %.% summarise(mindate=min(date))


 ID    mindate
1  a  327283200
2  b -296352000
3  c -238723200
4  d  -27648000
  • I expected the function to return the date.
  • additional question: Is it possible to get an return with all colums of the original data.frame? I tried to use select() etc., but I never got back the 'big' & summerised data.frame.

Thank you!
Manuel

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions