R Array subsetting: flexible use of drop -


as has been noticed in subsetting r array: dimension lost when length 1 r drops every dimension when subsetting , length 1.

the drop property helps avoid that. need more flexible way subset :

> arr = array(1, dim= c(1,2,3,4)) > dim(arr[,,1,]) [1] 2 4 > dim(arr[,,1,,drop=f]) [1] 1 2 1 4 

i want way subset dropping 3rd dimension (actually dimension put subset 1) , keepping 1st dimension (the dimensions no subset put).

it should return array dimension = 1 2 4

my issue started coding array no dimension = 1, when coming deal cases dimension 1, crashes. function need provides way deal array if dimension not 1.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -