Hello again, Let say I have 1 matrix:
Mat <- matrix(1:12, 4, 3) rownames(Mat) <- letters[1:4] Now I want to subscript of Mat in following way: Subscript_Vec <- c("a", "e", "b", "c") However when I want to use this vector, I am geting following error: Mat[Subscript_Vec, ] Error: subscript out of bounds Basically I want to get my final matrix in following way: V1 V2 V3 a 1 5 9 e NA NA NA b 2 6 10 c 3 7 11 i.e. if some of the element(s) in 'Subscript_Vec' is not in 'Mat' then that row would be filled by NA, WITHOUT altering the sequence of 'Subscript_Vec' Is there any direct way to achieve that? Thanks and regards, ______________________________________________ R-help@r-project.org mailing list 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.