I have a problem in converting a vector into date one by using as.Date
.
Data is as below.
> new3<-read.csv("Total Load - Day Ahead _ Actual.csv",stringsAsFactors=F)
> colnames(new3)<- c("Date","Hour","Dayahead","Actual")
> str(new3)
'data.frame': 35044 obs. of 4 variables:
$ Date : chr "01-01-2015" "01-01-2015" "01-01-2015" "01-01-2015" ...
$ Hour : chr "0:00" "0:15" "0:30" "0:45" ...
$ Dayahead: chr "42955" "42412" "41901" "41355" ...
$ Actual : int 42425 42021 42068 41874 41230 40810 40461 40160 39958
...
Here, I tried as.Data
new3$Date<-as.Date(new3$Date,"%d/%m/%Y")
The order of d,m,Y is right. But when I do this, it shows me NA in date info as below
> str(new3)
'data.frame': 35044 obs. of 4 variables:
$ Date : Date, format: NA NA NA NA ...
$ Hour : chr "0:00" "0:15" "0:30" "0:45" ...
$ Dayahead: chr "42955" "42412" "41901" "41355" ...
$ Actual : int 42425 42021 42068 41874 41230 40810 40461 40160 39958
...
I don't know what to do to fix it.
Can anyone help me out here? Thank you