I have a data set of the following form:
Store Dept Date Weekly_Sales IsHoliday
1 1 1 2010-02-05 24924.50 FALSE
2 1 1 2010-02-12 46039.49 TRUE
3 1 1 2010-02-19 41595.55 FALSE
4 1 1 2010-02-26 19403.54 FALSE
5 1 1 2010-03-05 21827.90 FALSE
6 1 1 2010-03-12 21043.39 FALSE
This data extends as: There are 99 Dept in each stores and there are 45 stores. I wanted the data to be split among individual Dept of individual Stores. Hence the following code:
train<- read.csv("train.csv")
splitData<-lapply(split(train,as.factor(train$Store)),FUN= function(x)split(x,x$Dept) )
Now, splitData[[1]][1][[1]]
contains the tuples corresponding to 1st Dept of 1st store.
I need to plot the graph of date vs Weekly_Sales. So, I used the method mentioned in the accepted method here and did:
splitData[[1]][1][[1]]$Date <- strptime(splitData[[1]][1][[1]]$Date, format="%Y/%m/%d")
But to my surprise, the Date form got converted into NA values. Following is a snapshot of data:
Store Dept Date Weekly_Sales IsHoliday
1 1 1 <NA> 24924.50 FALSE
2 1 1 <NA> 46039.49 TRUE
3 1 1 <NA> 41595.55 FALSE
4 1 1 <NA> 19403.54 FALSE
5 1 1 <NA> 21827.90 FALSE
6 1 1 <NA> 21043.39 FALSE
Can anybody tell me what am I doing wrong and the correct method to do so?