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 B

[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:1873

Re: [R] select a subset from a sample

2011-01-23 Thread Den
Maybe that: su <- lapply(dat[2:5],function(x)table(x)) su mode(su) myBYdata <- data.frame( do.call(cbind,lapply(su, as.data.frame)) ) myBYdata У Няд, 23/01/2011 у 07:43 -0500, Wei Yang піша: > Dear all, > > I would like to ask whether anyone has experience with the problem below. > > > I want

Re: [R] select a subset from a sample

2011-01-23 Thread Ista Zahn
I think there are multiple solutions that match your criteria. Here is one: dat <- structure(list(Id = 1:20, v1 = c(1L, 2L, 4L, 1L, 3L, 3L, 3L, + 4L, 1L, 4L, 2L, 1L, 2L, 4L, 3L, 2L, 1L, 2L, 4L, 3L), v2 = c(2L, + 1L, 2L, 1L, 2L, 1L, 4L, 4L, 2L, 1L, 4L, 4L, 3L, 3L, 2L, 3L, 4L, + 3L, 1L, 3L), v3 = c(

[R] select a subset from a sample

2011-01-23 Thread Wei Yang
Dear all, I would like to ask whether anyone has experience with the problem below. I want to select a subset of the sample (see data below) so that each level (1,2,3,4 in the example) for every variable (v1,v2,v3,v4 in the example) is shown at least once in the subset. I also want the sample s

Re: [R] select a subset

2008-11-25 Thread Stavros Macrakis
How about something like: censor_choose <- function(fr) do.call(rbind, lapply( split( fr, fr$id), function(sub) sub[which.max( if (max(sub$censor)) sub$censor else sub$time) ,] ) ) Using your data, itc <- data.frame(id=c(1,1,1,2

Re: [R] select a subset

2008-11-24 Thread Stefan Grosse
gallon li schrieb: > for id 1, i want to select the last row since all censor indicator is 0; for > id 2, i want to select the row where censor ==1; for id 3, i also want to > select the row where censor==1. So if there is a 1 for censor, then I want > to select such a row, otherwise I want to sele

[R] select a subset

2008-11-24 Thread gallon li
I have the complete data like id time censor 1 10 0 1 20 0 1 30 0 2 10 0 2 20 1 2 30 0 2 40 0 3 10 0 3 20 0 3 30 1 for id 1, i want to select the last row since all censor indicator is 0; for id 2, i want to select the row where censor ==1; for id 3, i also want to select the row where censo