Description Usage Arguments Details Value Author(s) Examples
Subdivides interval data on long-format into shorter intervals such that
every value in intTimes
is a boundary point of the
subdivided intervals.
1 | RefineTimeScale(A, startTimeName, stopTimeName, intTimes, endStatusName, intStatusName=NULL)
|
A |
Data frame with interval data on 'long-format'. |
startTimeName |
Name of column in |
stopTimeName |
Name of column in |
intTimes |
The time points that should subdivide the intervals in |
endStatusNames |
The names of the columns in |
intStatusNames |
The names of the columns in |
Each row represents a transition, that occurs at the end of the interval, from the interval
state to the right boundary state. If endStatusName
is NULL
then
the state at the imputed right boundaries are set to FALSE
, otherwise
they are set to the corresponding interval states. The remaining observations
are assumed to occur at the left boundaries.
Data frame with subdivided intervals.
Kjetil Røysland <kjetil.roysland@medisin.uio.no>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (A, startTimeName, stopTimeName, intTimes, endStatusName)
{
N <- nrow(A)
q <- N * (length(intTimes) + 1)
r <- .C("intersect", as.double(A[, startTimeName]), as.double(A[,
stopTimeName]), as.integer(N), as.double(intTimes), as.integer(length(intTimes)),
newIntStart = double(q), newIntStop = double(q), newOLine = integer(q),
newNRows = integer(1))
W <- data.frame(r$newOLine, r$newIntStart, r$newIntStop)
if (r$newNRows < q)
W <- W[-((r$newNRows + 1):q), ]
names(W) <- c("imputation", startTimeName, stopTimeName)
A <- A[, !(names(A) %in% c(startTimeName, stopTimeName))]
A <- cbind(A, imputation = 1:N)
A <- merge(W, A, by.x = "imputation", by.y = "imputation",
sort = FALSE)
A$imputation <- duplicated(A$imputation, fromLast = TRUE)
A[A$imputation, names(A) %in% as.character(endStatusName)] <- FALSE
A <- subset(A, select = -imputation)
return(A)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.