I have 451 dates in the format "2002-06-18",YYYY-MM-DD, in the spreadsheet program libre office calc. I would like to transfer these dates into R as a column with the name "Date_Sale".
In the next step I copied this column of dates to a text file. In the next step I read this text file into R by the command
Date_Sale <- read.csv("Date_Sale.txt", header=FALSE,stringsAsFactors=FALSE)
> str(Date_Sale)
'data.frame': 451 obs. of 1 variable:
$ V1: chr "2002-06-18" "2002-05-22" "2002-05-23" "2002-10-23" ...
Above the command str etc. shows that the data was read as dataframe in the format chr, character, into R. Now I tried to use the command
Date_Sale <- strptime(Date_Sale, "%Y-%m-%d")
There appears the error message
Fehler in strptime(Date_Sale, "%Y-%m-%d") :
Eingabe-Zeichenkette ist zu lang
If I use one element in the command above it works.
firstday <- strptime("2002-06-18", "%Y-%m-%d")
[1] "2002-06-18 CEST"