Hi,

Let say I have below matrix

mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol = 3, byrow = TRUE,
               dimnames = list(c("row1", "row2"),
                               c("C.1", "C.2", "C.3")))


Now I can extract a raw by rowname as

> mdat['row1', ]

C.1 C.2 C.3

  1   2   3


However I am also looking for was to extract values as NA when a
rowname is supplied which is not existing rownames

I should get

> mdat['new_raw', ]

C.1 C.2 C.3

  NA   NA   NA


Current it throws error as default functionality. Is there any way to
force R to provide values as NA instead of showing any errore?

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to