Re: [R] Subset and sumerize

2016-10-14 Thread Mark Sharp
Ashta, ## I may have misunderstood your question and if so I apologize. ## I had to remove the extra line after "45" before ## the ",sep=" to use your code. ## You could have used dput(dat) to send a more reliable (robust) version. dat <- structure(list(ID = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L,

Re: [R] Subset and sumerize

2016-10-14 Thread Sarah Goslee
For the data you provide, it's simply: summary(subset(dat, x1 == "x" & x2 == "z")$y) Note that x1 and x2 are factors in your example. We also don't know what you want to do if there are more than one combination of that per ID, or if there ID values with no matching rows. Sarah On Fri, Oct 14,

[R] Subset and sumerize

2016-10-14 Thread Ashta
Hi all, I am trying to summarize big data set by selecting a row conditionally. and tried to do it in a loop Here is the sample of my data and my attempt dat<-read.table(text=" ID,x1,x2,y 1,a,b,15 1,x,z,21 1,x,b,16 1,x,k,25 2,d,z,31 2,x,z,28 2,g,t,41 3,h,e,32 3,x,z,38 3,x,g,45 ",sep=",",he