I have a table(csv file) where first two attributes are store and dept and then there are other attributes like Date, Sales etc. The table is as follows:-
Store Dept Date Sales Holiday
1 1 ... ... ... (... means some random value)
1 1 ... ... ...
1 2 ... ... ...
1 2 ... ... ...
1 3 ... ... ...
2 1 ... ... ...
2 1 ... ... ...
2 2 ... ... ...
2 2 ... ... ...
Now first I loaded this file into a train variable:-
train<- read.csv("train.csv")
Then, I divided/grouped it based on Store:
dataByStore<- split(train, train$Store)
Now, I want to dataByStore and divide it as per department. So, as a result I will get data of each department of each store. I think for this, I will have to initialise an array of the size of the number of stores eg: dataByStoredept, and for each store i do
dataByStoreByDept[i]<- split(dataByStore[i], dataByStore[i]$Dept)
So, dataByStoreByDept[i][0] will contain the first department data of store i and so on. Can anyone tell me the syntax to do this as I don't know how to declare such a 2d array. A short explanation with few lines of code would suffice.
Do mention if any of my presumptions above are wrong.
Update:
For the third step, I want to write a function which should go as follows(Its only the syntax that I don't know):
dataByStoreByDept<- array(seq_len(dataByStore)) -------> seq_len(dataByStore) is the number of stores
for(i in seq_len(dataByStore)){
dataByStoreByDept[i]<- split(dataByStore, dataByStore$dept)
}