[Traminer-users] ID variable in TSE Data
Matthias Studer
Matthias.Studer at unige.ch
Mon Dec 16 09:07:00 CET 2013
Dear Lucas,
The « id » argument should be the name of the column containing the « id » variable, not a vector. Hence try :
data.tse <- seqformat(data, 2:6, from="STS", to = "TSE", tevent=transition2, id="id")
or
data.tse <- seqformat(data, 2:6, from="STS", to = "TSE", tevent=transition2, id="pid")
Hope this helps.
Matthias
De : traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] De la part de Lucas Rich
Envoyé : jeudi 12 décembre 2013 22:37
À : traminer-users at lists.r-forge.r-project.org
Objet : [Traminer-users] ID variable in TSE Data
I am trying to get an id variable into TSE data so I can match event data with other data that is indexed with this ID variable. I kept running into problems doing this, and after trying a number of things, I found that whether this works depends on the name that I use for this ID variable, which seems strange. So the following code works and correctly pulls the ID variable into the TSE data.
id <- c(10,20,30,40)
t1 <- c(1,1,1,1)
t2 <- c(1,2,NA,1)
t3 <- c(1,NA,2,1)
t4 <- c(2,2,2,2)
t5 <- c(1,1,2,2)
data <- data.frame(id,t1,t2,t3,t4,t5)
data.seq <- seqdef(data, 2:6, labels = c("NotDisabled","Disabled"),id=data$id)
transition2 <- seqetm(data.seq, method="transition")
data.tse <- seqformat(data, 2:6, from="STS", to = "TSE", tevent=transition2, id=data$id)
However, if I change the name of the ID variable, then I get the following error:
Error in `[.data.frame`(x, r, vars, drop = drop) :
undefined columns selected
For instance, if I just change the name and run the code again with the new variable name, then I get the error (only for the seqformat command, the seqdef command works fine):
names(data)[1] <- "pid"
data.seq <- seqdef(data, 2:6, labels = c("NotDisabled","Disabled"),id=data$pid)
data.tse <- seqformat(data, 2:6, from="STS", to = "TSE", tevent=transition2, id=data$pid)
Am I missing some reason why the former name works but not the latter?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20131216/34c440f3/attachment.html>
More information about the Traminer-users
mailing list