In a first large Loop I generated 1,000,000 matrices XY_1_1, ..., XY_1000_1000:
for (i in 1:1000){
for (j in 1:1000){
assign(paste0("XY",i,j ,sep='_'), matrix(ncol=10, nrow=4))
}
}
Now I want to assign different outcomes of a function (vector of length 10) to the rth row of the matrices, which should somehow like this:
for (r in 1:4){
for (i in 1000){
for (j in 1:1000){
assign(paste0("XY",i,j ,sep='_')[r,], function(i,j,r))
}
}
}
Unfortunately, I get the error 'incorrect number of dimensions'.
Furthermore, I tried using the get()-Function:
for (r in 1:4){
for (i in 1000){
for (j in 1:1000){
get(paste0("XY",i,j ,sep='_'))[r,] <- function(i,j,r)
}
}
}
which brought the error 'target of assignment expands to non-language object'. Does anyone know a proper solution? Let me know in case you need further information.