[Rd] Puzzle or bug with matrix indexing
ccberry @ending from uc@d@edu
Sat Aug 4 18:53:30 CEST 2018
> On Aug 4, 2018, at 6:55 AM, David Hugh-Jones <davidhughjones using gmail.com> wrote:
> I'm not sure why this is happening:
> tmp <- data.frame(
> a = letters[1:2],
> b=c(TRUE, FALSE),
> stringsAsFactors = FALSE
> idx <- matrix(c(1, 2, 2, 2), 2, byrow = TRUE)
>  " TRUE" "FALSE"
Matrix indexing (x[i] with a logical or a 2-column integer matrix i) using [ is not recommended. For extraction, x is first coerced to a matrix.
Thus, something like
happens converting every column to character. Dig deeper by reading
and see the paragraph on `as.matrix' under `Details'.
More information about the R-devel