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 directoryoldway= read.csv("testfile.csv", stringsAsFactor=F) # read in using base Rnewway= 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
The text was updated successfully, but these errors were encountered:
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:
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
The text was updated successfully, but these errors were encountered: