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,
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,
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
3 matches
Mail list logo