I have a long matrix (ncol=6 and nrow=50,000,000+). I want to transform it into a list of matrices where:
[i,4] and [i,5] are names (or keys) of the list,
[i,1] is the date,
[i,2] and [i,3] are time of the day,
[i,6] is the value to be stored in the list.
The matrices in the list are all be the same dimensions.
for (i in seq(1, nrow(a2015_15))) {
OD_L_2015_15[[
paste(a2015_15[i,4], a2015_15[i,5])
]] [
a2015_15[i,1], paste(a2015_15[i,2], a2015_15[i,3])
] =
as.numeric(a2015_15[i,6])
}
As is, it takes an hour or two to run which is a pain especially on a slower computer.
Any suggestions to make this run quicker perhaps with an apply statement? I tried to limit the calls to a2015_15 (by saving a2015_15[i,] and then referencing it) but it didn't seem to help.
Thanks.
Edit: Here's the matrix I want to change:
The list would be split into: OD_L_2015_15[[Key1,Key2]][Date,c(Time,Time2)]=Value
dput
? - 10 or so will do - just so we have something reproducible to play with. – thelatemaildata.table
? – Uwe