因此,我有一些日期列表,由于以下原因,我无法完全将其视为日期:
Error in charToDate(x) : character string is not in a standard unambiguous format
数据以字符向量形式输入,并在最后一行代码之后转换为未知数据。我最终希望在这些日期之前对数据进行排序,但是由于这些数据被视为字符向量,因此无法正确排列。
样本数据: http://www.fast-files.com/getfile.aspx?file=191192 http://www.fast-files.com/getfile.aspx?file=191193
library("xlsx")
library("readxl")
library("dplyr")
library("data.table")
library("tidyverse")
library("lubridate")
library("zoo")
library("stringr")
A <- read_csv("A.csv")
B <- read_csv("B.csv")
C<- rbind(A,B)
C[C=="/ /"]<-NA
as.Date(C$`ROLL OUT SHIP DATE`)
format <- guess_formats(c(C$`ROLL OUT SHIP DATE`), c("mdY", "BdY", "Bdy", "bdY", "bdy", "mdy", "dby"))
C$`ROLL OUT SHIP DATE` <-as.Date(strptime(C$`ROLL OUT SHIP DATE`, format))
a.csv数据:
"Due Date","ROLL OUT SHIP DATE","Vendor Ship Date"
"04/01/2019","/ /","02/25/2019"
"06/06/2019","/ /","04/30/2019"
"04/01/2019","/ /","02/25/2019"
"03/09/2019","/ /","/ /"
"03/09/2019","/ /","/ /"
"03/09/2019","/ /","/ /"
"05/01/2019","/ /","03/25/2019"
"05/10/2019","/ /","04/03/2019"
"05/01/2019","/ /","03/25/2019"
"05/10/2019","04/01/2019","04/03/2019"
"04/24/2019","05/01/2019","03/25/2019"
"03/09/2019","/ /","/ /"
"/ /","/ /","/ /"
b.csv:
"Due Date","ROLL OUT SHIP DATE","Vendor Ship Date"
"04/06/2019","04/07/2019","03/13/2019"
"04/21/2019","04/07/2019","04/03/2019"
"03/30/2019","02/18/2019","03/04/2019"
"03/30/2019","/ /","03/04/2019"
"02/10/2019","/ /","/ /"
"04/05/2019","/ /","02/25/2019"
"06/14/2019","/ /","05/01/2019"
"03/08/2019","/ /","01/21/2019"
"03/08/2019","/ /","01/21/2019"
"03/22/2019","/ /","02/04/2019"
"03/31/2019","04/08/2019","02/25/2019"
"08/03/2019","/ /","06/20/2019"
"08/03/2019","/ /","06/20/2019"
"03/04/2019","/ /","/ /"
"07/30/2019","/ /","06/16/2019"
"07/30/2019","/ /","06/23/2019"
"03/25/2019","/ /","/ /"
"03/29/2019","/ /","/ /"
"03/29/2019","/ /","/ /"
"03/29/2019","/ /","/ /"
"03/29/2019","/ /","/ /"
"03/31/2019","/ /","02/25/2019"
"05/14/2019","/ /","04/01/2019"
"06/17/2019","/ /","05/05/2019"
"03/07/2019","/ /","01/20/2019"
"06/07/2019","/ /","05/01/2019"
"03/16/2019","04/08/2019","01/28/2019"
"03/16/2019","/ /","02/05/2019"
"04/11/2019","/ /","03/05/2019"
"05/15/2019","/ /","04/08/2019"
"06/09/2019","/ /","05/03/2019"
"05/08/2019","/ /","04/01/2019"
"06/12/2019","/ /","04/29/2019"
"/ /","/ /","/ /"
"/ /","/ /","/ /"