2

I import data from excel and I have multiple excel so I read at one time.
Here is my code:

library(readxl)
library(data.table)
file.list <- dir(path = "path/", pattern='\\.xlsx', full.names = T)
df.list <- lapply(file.list, read_excel)
data <- rbindlist(df.list)  

However, I get this warning messages between df.list <- lapply(file.list, read_excel) and data <- rbindlist(df.list).

Warning messages:
1: In read_xlsx_(path, sheet, col_names = col_names, col_types = col_types,  :
[3083, 9]: expecting date: got '2015/07/19'
2: In read_xlsx_(path, sheet, col_names = col_names, col_types = col_types,  :
[3084, 9]: expecting date: got '2015/07/20'

What's going on? How can I check and correct?

Jaap
  • 81,064
  • 34
  • 182
  • 193
Peter Chen
  • 1,464
  • 3
  • 21
  • 48
  • 2
    Have you looked into your excel sheet at the respective lines? to me it seems that there is something going on there. maybe you have an empty cell before or after these lines, some space or anything like that... or the format of your date is different in these ones from what is in the other cells... something in that direction – Sarina Apr 21 '17 at 06:32
  • 1
    Instead of use "path" set your working directory with setwd("path/to/file") and it should be easier to navigate when you have an issue. – Chef1075 Apr 21 '17 at 07:24
  • Also have your tried `read.csv()` instead? it might make uploading the file into r easier. – Chef1075 Apr 21 '17 at 07:26
  • thanks a lot. I solved. @Sarina, your right. – Peter Chen Apr 21 '17 at 07:43

2 Answers2

1

According to my comment I submit this as an answer. Have you looked into your excel sheet at the respective lines? to me it seems that there is something going on there. maybe you have an empty cell before or after these lines, some space or anything like that... or the format of your date is different in these ones from what is in the other cells.

Sarina
  • 548
  • 3
  • 10
  • I got this warning message because R identify them to be a charactor rather than a date format. I don't know why in my all data just these 2 obs. happen? But i delete that 2 cells and type again by myself, the problem solved. – Peter Chen Apr 21 '17 at 08:51
  • 1
    It might be that you had an extra empty space there, sometimes this happens (I have that often with species names) and it can be really confusing to find these kind of errors but I am glad I was able to help you and this might help others as well – Sarina Apr 21 '17 at 09:02
1

It is not an elegant solution but use the parameter guess_max = "number of lines in your data file"; this eliminates the warnings and the side effects.

C Lederman
  • 19
  • 4