| CreateTrans | R Documentation |
A function used to create transition vectors with data in long format, which requires the dplyr package.
CreateTrans(ID, Age, State, Death, states)
ID |
A vector that specifies the ID for each subject. |
Age |
A vector that indicates each subject's age at this visit. |
State |
A vector or a factor that indicates the state for each subject at this visit. |
Death |
A vector that indicates whether the subject died or not at this visit. |
states |
The total number of states in our data. |
The rules for creating transitions can be found with ?lifedata. In essence, arrange the data in long format, including details about the present state at time t. This procedure will assist in generating a dataset in long format that captures transitions by utilizing states from both time t-1 and t.
A vector that contains all transitions.
lifedata
ID <- rep(1:50, each = 5)
Age <- rep(31:35, times = 50)
State <- sample(1:5,size=250,replace=TRUE)
Death <- rep(c(0,0,0,0,1),times=50)
Example <- data.frame(ID,Age,State,Death)
Example$trans <- CreateTrans(Example$ID,Example$Age, Example$State,Example$Death,states=6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.