## UPDATE:


# Live and Learn: 
#  This is unneeded. 
#
# You can index directly 

identical(
      myarr[, 6:8, ]
      , sampleArray(myarr, dm=2, start=6, leng=3)
        )
# [1] TRUE


xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


##################################################
#------------------------------------------------

  sampleArray <- function(myarr, dm, start=1, leng=dim(myarr)[dm]-start+1, drop=FALSE) {
  ##  Samples from a given 
  ##
  ## arguments: 
  ##  dm is the dimension selected
  ##  start is where in dm to being
  ##  leng is how far in from dm to go 
  ##  drop is passed through to indexing 
  ##   start+leng-1 <= dim(myarr)[dm]
    
    leng <- leng-1

    # error check
    if (start+leng > dim(myarr)[dm])
      warning("leng too long by ", start+leng - dim(myarr)[dm], ".")

    #initialize a vector of all TRUE
    indx <- as.list(rep(TRUE, length(dim(myarr))))

    # change the required dimension to the required sequence
    indx[[dm]] <- seq(start, start+leng)
    indx <- paste(indx, collapse=",")

    expr <- paste0("myarr[", indx, ", drop=drop]")

    # return the appropriate sample
    eval(parse(text=expr))
  }


  #------------------------------------------------

  examples: 

      # sample array
      myarr <- array(1:2250, dim=c(15, 10, 15))

      # example call
      sampleArray(myarr, dm=2, start=6, leng=3)

      # difference between drop
      sampleArray(myarr, dm=2, start=10)  #same as drop=FALSE)
      sampleArray(myarr, dm=2, start=10, drop=TRUE)

      # will give error
      sampleArray(myarr, dm=2, start=7, leng=5)

#------------------------------------------------
##################################################
