Re: [R] Subset of matrix

From: jim holtman <jholtman_at_gmail.com>
Date: Tue, 25 Mar 2008 07:23:32 -0500

my.mat[rownames(my.mat) in c(5951, 236, 6306, 5950, 145742, 1123),]

or something close to this. Need to read introduction to R and subsetting.

On 3/24/08, dinesh kumar <barupal_at_gmail.com> wrote:
> Dear R users
>
> I have a big matrix like
>
> 6021 1188 790 290 1174 1015 1990 6613 6288
> 100714
> 6021 1 0.658 0.688 0.474 0.262 0.163 0.137 0.32
> 0.252 0.206
> 1188 0.658 1 0.917 0.245 0.331 0.122 0.148 0.194
> 0.168 0.171
> 790 0.688 0.917 1 0.243 0.31 0.122 0.15 0.19
> 0.171 0.174
> 290 0.474 0.245 0.243 1 0.39 0.319 0.187 0.4
> 0.311 0.235
> 1174 0.262 0.331 0.31 0.39 1 0.295 0.352 0.345
> 0.306 0.308
> 1015 0.163 0.122 0.122 0.319 0.295 1 0.421 0.343
> 0.442 0.435
> 1990 0.137 0.148 0.15 0.187 0.352 0.421 1 0.313
> 0.38 0.395
> 6613 0.32 0.194 0.19 0.4 0.345 0.343 0.313 1 0.58
> 0.429
> 6288 0.252 0.168 0.171 0.311 0.306 0.442 0.38 0.58
> 1 0.723
> 100714 0.206 0.171 0.174 0.235 0.308 0.435 0.395
> 0.429 0.723 1
> 5951 0.22 0.168 0.171 0.267 0.318 0.478 0.409 0.478
> 0.844 0.85
> 5960 0.232 0.183 0.186 0.272 0.324 0.42 0.383 0.522
> 0.686 0.711
> 236 0.259 0.213 0.218 0.283 0.357 0.382 0.4 0.549
> 0.655 0.608
> 64956 0.199 0.172 0.175 0.25 0.355 0.444 0.475 0.523
> 0.633 0.614
> 239 0.188 0.169 0.173 0.237 0.362 0.463 0.5 0.469
> 0.596 0.692
> 33032 0.25 0.167 0.169 0.308 0.301 0.407 0.346 0.486
> 0.655 0.64
> 6262 0.254 0.178 0.182 0.314 0.329 0.396 0.36 0.459
> 0.679 0.633
> 5961 0.262 0.189 0.194 0.311 0.342 0.362 0.377 0.468
> 0.621 0.574
> 5962 0.243 0.177 0.18 0.298 0.324 0.389 0.353 0.453
> 0.667 0.62
> 6306 0.226 0.168 0.171 0.274 0.306 0.389 0.38 0.514
> 0.698 0.62
> 6106 0.226 0.168 0.171 0.274 0.306 0.389 0.38 0.514
> 0.698 0.62
> 6287 0.208 0.175 0.178 0.25 0.328 0.429 0.422 0.529
> 0.771 0.689
> 5950 0.193 0.175 0.179 0.23 0.344 0.465 0.5 0.448
> 0.733 0.816
> 833 0.312 0.244 0.242 0.408 0.444 0.328 0.317 0.526
> 0.562 0.517
> 750 0.168 0.155 0.157 0.208 0.339 0.514 0.515 0.385
> 0.578 0.722
> 6137 0.201 0.168 0.171 0.239 0.306 0.389 0.38 0.453
> 0.698 0.62
> 145742 0.317 0.229 0.236 0.349 0.325 0.339 0.305
> 0.519 0.581 0.534
> 5810 0.364 0.216 0.221 0.411 0.294 0.338 0.269 0.603
> 0.631 0.47
> 825 0.364 0.216 0.221 0.411 0.294 0.338 0.269 0.603
> 0.631 0.47
> 7405 0.313 0.246 0.244 0.355 0.367 0.29 0.317 0.537
> 0.507 0.484
> 1045 0.133 0.124 0.135 0.198 0.333 0.441 0.344 0.277
> 0.362 0.341
> 1123 0.11 0.106 0.104 0.157 0.262 0.415 0.368 0.227
> 0.304 0.333
> 588 0.281 0.312 0.34 0.303 0.419 0.278 0.4 0.287
> 0.312 0.316
>
> with more than thousand number of rows and column
> I want to extract or subset a child matrix from above with specific row
> names or col names.
> e.g.
> For above matrix I need only rows which has following row names.
> 5951 236 6306 5950 145742 1123
>
> I would appreciate if you can use this matrix as input.
>
> Thanks in advance.
>
> Dinesh
>
>
>
>
> --
> Dinesh Kumar Barupal
> Research Associate
> Metabolomics Fiehn Lab
> UCD Genome Center
> 451 East Health Science Drive
> GBSF Builidng
> University of California
> DAVIS
> 95616
> http://fiehnlab.ucdavis.edu/staff/kumar
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
R-help_at_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.
Received on Tue 25 Mar 2008 - 13:07:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 25 Mar 2008 - 14:00:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive