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

datetime columns are treated like date columns in read_csv #136

Closed
metanoid opened this issue Apr 17, 2015 · 0 comments
Closed

datetime columns are treated like date columns in read_csv #136

metanoid opened this issue Apr 17, 2015 · 0 comments

Comments

@metanoid
Copy link

I have some columns in which all values are in the format "%Y-%m-%d %H:%M:%S". However, read_csv seems to expect that this column be inthe format "%Y-%m-%d" (i.e. it assumes that my datetime is a date). Reproducible example follows:

require(readr)
 x = structure(list(TOTALPICKUPVOLUME = c(7.44155096355823, 3.50648998282849, 5.51947497297077, 4.02596998028456, 6.01298097055403, 6.84414896648375 ), 
TOTALVOLUME = c(7.8658189019188, 5.60414088983087, 8.16610293881966, 4.54643564159049, 6.19073503790421, 7.48468671925364), 
TIME_ = c(0.22298695605972, 0.203827603700878, 0.160576058136672, 0.173956024614508, 0.145875614476142, 0.083385205620664), 
START = c("2013-08-13 04:07:47", "2013-08-13 09:28:53", "2013-08-13 14:22:24", "2013-08-13 18:13:38", "2013-08-13 22:24:08", "2013-08-14 05:55:13"), 
FINISH = c("2013-08-13 09:28:53", "2013-08-13 14:22:24", "2013-08-13 18:13:38", "2013-08-13 22:24:08", "2013-08-14 01:54:11", "2013-08-14 07:55:18"), 
SDATE = c("2013-08-13", "2013-08-13", "2013-08-13", "2013-08-13", "2013-08-13", "2013-08-14"),
 DEPOTCODE = c(1609L, 1609L, 1609L, 1609L, 1609L, 1609L)), 
.Names = c("TOTALPICKUPVOLUME", "TOTALVOLUME", "TIME_", "START", "FINISH", "SDATE", "DEPOTCODE" ), 
row.names = c(NA, 6L), 
class = "data.frame") #create some example data
write.csv(x, file = "testfile.csv") #save it in the current working directory
oldway = read.csv("testfile.csv", stringsAsFactor = F) # read in using base R
newway = read_csv("testfile.csv") # read in using readr::read_csv
problems(newway) # display mismatch issue

Source: local data frame [12 x 4]

row col expected actual
1 1 5 date like %Y-%m-%d 2013-08-13 04:07:47
2 1 6 date like %Y-%m-%d 2013-08-13 09:28:53
3 2 5 date like %Y-%m-%d 2013-08-13 09:28:53
4 2 6 date like %Y-%m-%d 2013-08-13 14:22:24
5 3 5 date like %Y-%m-%d 2013-08-13 14:22:24
6 3 6 date like %Y-%m-%d 2013-08-13 18:13:38
7 4 5 date like %Y-%m-%d 2013-08-13 18:13:38
8 4 6 date like %Y-%m-%d 2013-08-13 22:24:08
9 5 5 date like %Y-%m-%d 2013-08-13 22:24:08
10 5 6 date like %Y-%m-%d 2013-08-14 01:54:11
11 6 5 date like %Y-%m-%d 2013-08-14 05:55:13
12 6 6 date like %Y-%m-%d 2013-08-14 07:55:18

Expected behaviour: Column 5 and 6 column type is automatically detected as datetime.
Second best alternative: Column 5 and 6 read in as character
Actual behaviour: Column 5 and 6 populated with NA's

@hadley hadley closed this as completed in 518546a Apr 20, 2015
@lock lock bot locked and limited conversation to collaborators Sep 25, 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

1 participant