0

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.

  • 1
    Please show a small reproducible example and expected output – akrun Feb 10 '20 at 16:22
  • See here for information on how to create a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). That way you can help others to help you! – dario Feb 10 '20 at 16:32
  • Also somewhat related: https://stackoverflow.com/questions/20904827/the-representation-of-an-empty-argument-in-a-call – MrFlick Feb 10 '20 at 17:21

0 Answers0