Displaying 1 result from an estimated 1 matches for "mycensor".
Did you mean:
censor
2011 Aug 31
1
formatting a 6 million row data set; creating a censoring variable
...ensor function from above
library(data.table)
mydt <- data.table(myData)
setkey(mydt,id,mygroup)
timeData <- mydt[,list(mytime=length(gender)),by=list(id,mygroup)]
makeCensor <- function(x) {
myvec <- rep(0,length(x))
lastInd <- length(myvec)
myvec[lastInd] = 1
myvec
}
mycensor <- timeData[,list(censor=makeCensor(mygroup)),by=id]
datatableSolution <- cbind(timeData,mycensor[,list(censor)])