miss.chain <- function(x,time) { # # return a chain like x with NA's inserted whereever there is # a break in time. This function is used primarily to prepare x for # input into the functions count and gcount, which compute transition # matricies. # n<-(x) brk <- c(((time[2:n]-time[1:(n-1)]) > 1),F) k <- sum(brk) if (k == 0) { temp <- x } else { brks <- (1:n)[brk] temp <- x[1:brks[1]] if (k > 1) { for (i in 2:k) { temp <- c(temp,NA,x[(brks[i-1]+1):brks[i]]) } } temp <- c(temp,NA,x[(brks[k]+1):n]) } temp }