As stated in R documentation, the operator '[' is defined in this way:
x[i, j, ... , drop = TRUE]
Is there a way to redefine it in order to set drop
parameter default value to FALSE
?
`[` <- function(...) base::`[`(...,drop=FALSE)
This should prevent some undesirable behaviour in R where a matrix that is reduced to one row or one column will suddenly behave like a c(number,number,number)
instead of matrix(c(number,number,number),ncol=1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With