Alternative drop = FALSE or change default behavior

The default behavior in R to reduce a two-dimensional matrix to 1 row is to actually reset the measurement. This can be “fixed” by setting drop = FALSE at the end of the matrix search. Is there any way to do this by default? I have a rather long program, and I realized that I would have to add this to about 100 places, if not ... I was looking for options ,? '[', And? The matrix is ​​inconclusive.

+5
source share
1 answer

You can override `[`as follows:

old <- `[`
`[` <- function(...) { old(..., drop=FALSE) }

, . . , , , , .

, , ?

- , . , , , , .

+5

All Articles