Re: [R] delete selecting rows and columns
A one-dimensional delete might be faster: n - 4000 m - 0.01 matr - matrix(1:(n^2), n, n) excl_r - sample(n, m*n) incl_r - setdiff(1:n, excl_r) excl_c - sample(n, m*n) incl_c - setdiff(1:n, excl_c) system.time(matr[-excl_r, -excl_c]) system.time( { m4 - matr[outer(incl_r, incl_c, function(i, j) i + n*(j - 1)) ] dim(m4) - c(length(incl_r), length(incl_c)) } ) Heikki Kaskelma jastar wrote: Hi, I'm working with a big square matrix (15k x 15k) and I have some trouble. I want to delete selecting rows and columns. I'm using something like this: sel_r=c(15,34,384,985,4302,6213) sel_c=c(3,151,324,3384,7985,14302) matrix=matrix[-sel_r,-sel_c] but it works very slow. Does anybody know how to make it in faster way? __ R-help@stat.math.ethz.ch 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.
Re: [R] delete selecting rows and columns
I mean something like in MATLAB matrix(sel_r,:)=[] jastar wrote: Hi, I'm working with a big square matrix (15k x 15k) and I have some trouble. I want to delete selecting rows and columns. I'm using something like this: sel_r=c(15,34,384,985,4302,6213) sel_c=c(3,151,324,3384,7985,14302) matrix=matrix[-sel_r,-sel_c] but it works very slow. Does anybody know how to make it in faster way? Thank's -- View this message in context: http://www.nabble.com/delete-selecting-rows-and-columns-tf3308726.html#a9327427 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] delete selecting rows and columns
Hi, I'm working with a big square matrix (15k x 15k) and I have some trouble. I want to deleting selecting rows and columns. I use something like this: sel_r=c(15,34,384,985,4302,6213) sel_c=c(3,151,324,3384,7985,14302) matrix=matrix[-sel_r,-sel_c] but it works very slow. Does anybody know how to make it in faster way? Thank's -- View this message in context: http://www.nabble.com/delete-selecting-rows-and-columns-tf3308726.html#a9203533 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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.