From rlucas11 at yahoo.com Thu Dec 12 22:37:14 2013 From: rlucas11 at yahoo.com (Lucas Rich) Date: Thu, 12 Dec 2013 13:37:14 -0800 (PST) Subject: [Traminer-users] ID variable in TSE Data Message-ID: <1386884234.7458.YahooMailNeo@web140502.mail.bf1.yahoo.com> 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: From Matthias.Studer at unige.ch Mon Dec 16 09:07:00 2013 From: Matthias.Studer at unige.ch (Matthias Studer) Date: Mon, 16 Dec 2013 08:07:00 +0000 Subject: [Traminer-users] ID variable in TSE Data In-Reply-To: <1386884234.7458.YahooMailNeo@web140502.mail.bf1.yahoo.com> References: <1386884234.7458.YahooMailNeo@web140502.mail.bf1.yahoo.com> Message-ID: <367AEF503B1B6A4EA602FB66D71A3EC70E941079@kilo.isis.unige.ch> 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: