Re: [R] Data transformation to list for event occurence

2013-11-13 Thread William Dunlap
ject: Re: [R] Data transformation to list for event occurence > > > > Hi Anindya, > > You may try: > dat1 <- read.table(text="ID   Week    Event_Occurence > A 1 0 > A 2 0 > A 3 1 > A 4 0 > B 1 1 > B 2 0 > B 3 0 > B 4 1",sep=""

Re: [R] Data transformation to list for event occurence

2013-11-12 Thread arun
Hi Anindya, You may try: dat1 <- read.table(text="ID   Week    Event_Occurence A 1 0 A 2 0 A 3 1 A 4 0 B 1 1 B 2 0 B 3 0 B 4 1",sep="",header=TRUE,stringsAsFactors=FALSE)  with(dat1,tapply(as.logical(Event_Occurence),ID,FUN=which )) #or lapply(split(dat1,dat1$ID),function(x) which(!!x[,3])) A.K

[R] Data transformation to list for event occurence

2013-11-12 Thread Anindya Sankar Dey
Hi, Say I have a following data ID WeekEvent_Occurence A 1 0 A 2 0 A 3 1 A 4 0 B 1 1 B 2 0 B 3 0 B 4 1 that whether an individual experienced an event in a particular week. I wish to create list such as the first element of the list will be a vector listing the week number when the event