I am dealing with a spatial dataset that I need to divide into a training and a validation subset.
To be specific, I have a raster with 31 bands; I need to use all of them as parameters for the division of the dataset into the two subsets. I wish to use the Kennard-Stone algorithm for the division, so I have looked into the two existing functions that can be used in R.
The first is the ken.sto in the soil.spec package. The second is the duplex in the cran package. The problem is that both of them require a matrix or a dataframe as the input, while I have a multilayer raster that I can only convert into an array. 
Does anyone have any suggestion on how to transform my spatial data, so that it can be used in one of the KS functions?