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=""
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
2 matches
Mail list logo