[R] select a subset of a matrix which one of its column meet a condition

2015-07-08 Thread Lida Zeighami
Hi there,

I have a matrix and I want to get a subset from that which one of its
matrix meet a condition,

my matrix is
met
 Row.names Name
maf   caf
1 10:13915  10:139  0.0003782148
0.0003782148
2 10:18738  10:18738   0.0003759398
 0.0003759398
3 10:100011321  10:100011321   0.0003762227
 0.0003762227
4 10:100012219  10:100012219   0.0007518797
0.0007518797
5 10:100013325  10:100013325  0.00
 0.00
6 10:100015404  10:100015404  0.00
0.00

I want to choose a subset from met which maf values are between 0 and
0.05 (0,0.05)

I wrote this code, but seem doesn't work properly:

 maf- met[which(c(met[,5]) %in% c(0,0.05)),]

the dim(maf)  is 0 so seems my code didn't work!
would please let me know how to correct it?

Thanks

[[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.


Re: [R] select a subset of a matrix which one of its column meet a condition

2015-07-08 Thread Rui Barradas

Hello,

Your matrix has only 4 columns but you refer to met[,5]. I'll assume 
you're refering to the last column, met[,4]. Try reading the help page 
for ?%in%, it doesn't do what you seem to think it does. And try using =.


maf - met[0 = met[, 4]  met[, 4] = 0.05, ]

Hope this helps,

Rui Barradas

Em 08-07-2015 16:37, Lida Zeighami escreveu:

Hi there,

I have a matrix and I want to get a subset from that which one of its
matrix meet a condition,

my matrix is
met
  Row.names Name
maf   caf
1 10:13915  10:139  0.0003782148
0.0003782148
2 10:18738  10:18738   0.0003759398
  0.0003759398
3 10:100011321  10:100011321   0.0003762227
  0.0003762227
4 10:100012219  10:100012219   0.0007518797
0.0007518797
5 10:100013325  10:100013325  0.00
  0.00
6 10:100015404  10:100015404  0.00
0.00

I want to choose a subset from met which maf values are between 0 and
0.05 (0,0.05)

I wrote this code, but seem doesn't work properly:


maf- met[which(c(met[,5]) %in% c(0,0.05)),]


the dim(maf)  is 0 so seems my code didn't work!
would please let me know how to correct it?

Thanks

[[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.



__
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.