I am new to using R, and so my question may be simple, but nonetheless I spent a lot of time figuring out what I am doing wrong, but to no avail. I found a lot of help on this site last week looking for other questions / answers (thanks!), But as someone new, it is often difficult to interpret other people's code.
I am trying to build a three-dimensional array of several data files, each of which has the same dimensions of 57x57.
Files = lapply(Sys.glob('File*.txt'), read.table, sep='\t', as.is=TRUE)
Files = lapply(Files[1:100], as.data.frame)
dim(Files[[1]])
[1] 57 57
Array = array(dim=c(57,57,100))
Array[,,1] = Files[1]
Array[,,2] = Files[2]
Error in Array[, , 2] = Files[2] : incorrect number of subscripts
Array[,,1] = Files[1]
Error in Array[, , 1] : incorrect number of dimensions
x = 0
for(i in 1:100){
Array[,,x+1] = Files[[i]]
x = x + 1
}
Error in Array[, , 1] = Files[[1]] :
incorrect number of subscripts
source
share