Hi, Try: f<-c(1,2) d[-seq_along(f),] # a b #[1,] 3 8 #[2,] 4 9 #[3,] 5 10 A.K.
----- Original Message ----- From: Andras Farkas <motyoc...@yahoo.com> To: r-help@r-project.org Cc: Sent: Wednesday, March 20, 2013 5:53 PM Subject: [R] remove specific number of rows from a matrix Dear All, sorry, got stuck again on the following: let us say we have: a <-c(1:5) b <-c(6:10) d <-cbind(a,b) from d I would like to remove total number of rows based on the length of f. So if: f <-c(1) my result is working great with the following solution: d[-length(f),] so I get: a b [1,] 2 7 [2,] 3 8 [3,] 4 9 [4,] 5 10 but if I do: f <-c(1,2) then I get: a b [1,] 1 6 [2,] 3 8 [3,] 4 9 [4,] 5 10 which tells us ideed, the code works well:-), but it is not what I need Instead, I wanted to remove row #1 adn row#2 from the matrix to get: [1,] 3 8 [2,] 4 9 [3,] 5 10 as the end result. Please provide your insights to solve this problem. Any input would be greatly appreciated, thanks, Andras [[alternative HTML version deleted]] ______________________________________________ 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. ______________________________________________ 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.