search for: makecensor

Displaying 1 result from an estimated 1 matches for "makecensor".

2011 Aug 31
1
formatting a 6 million row data set; creating a censoring variable
...;gender", "mygroup", "id"), class = "data.frame", row.names = c(NA, -20L)) # here is plyr solution with idata.frame library(plyr) imyData <- idata.frame(myData) timeData <- idata.frame(ddply(imyData, .(id,mygroup), summarize, mytime = length(mygroup))) makeCensor <- function(x) { myvec <- rep(0,length(x)) lastInd <- length(myvec) myvec[lastInd] = 1 myvec } plyrSolution <- ddply(timeData, "id", transform, censor = makeCensor(mygroup)) # here is a data table solution # use makeCensor function from above library(data.tabl...