aRrgh icon indicating copy to clipboard operation
aRrgh copied to clipboard

discuss dimension dropping

Open kevinushey opened this issue 11 years ago • 1 comments

m <- matrix(1:9, nrow=3)

class( m[1:2, ] ) ## matrix!
class( m[1, ] ) ## integer!

Useful when you're expecting it, the cause of difficult to trace bugs when you're not. The terribly wonderful syntax

m[1, , drop=FALSE]

allows you to avoid dimension dropping explicitly.

kevinushey avatar Nov 06 '13 07:11 kevinushey

Similarily, why apply is evil (always drops dimensions if the function applied returns a scalar*)

*vector of length one

kevinushey avatar Nov 13 '13 22:11 kevinushey