Say that we have an array a
with dimensions 10, 10, 10 or something. We can select columns of a
via a variable e.g. cols = c("colName1","colName2"); a[,cols,]
, etc.
Now let's say that we want to select all columns of a
, but want to do so via a variable as before. That is, we may want to return a[,,1]
, but using the variable cols
. So we want a[,cols,1]
to return the same as a[,,1]
. What should we set cols
to do this this? Is there something better/ more generic than cols=1:dim(a)[2]
? I tried using NULL
, but this didn't work, and just returned nothing.