Thanks, that did the trick. My "mclgen" function can be written as
mclgen <- function (datamat,catvar) { ncat <- nlevels(catvar) perschoice<-as.data.frame(rep(datamat,ncat)) perschoice<-reshape(perschoice,direction="long", varying=lapply(names(datamat),rep,ncat), timevar="newy") perschoice<-perschoice[sort.list(perschoice$id),] dep<-parse(text=paste("perschoice$",substitute(catvar),sep="")) perschoice$depvar<-as.numeric(eval(dep)==perschoice$newy) perschoice } I'd still appreciate the help of R-listers on how to use the value of "catvar" on the left-hand side of an expression within a function (perschoice$"valueof(catvar)"<-perschoice$newy), and how to get R to drop the reference category of a factor in an interaction effect without the main effect (in "clogit(depvar~occ+occ:educ+occ:black+strata(id),data=pc)"). But many thanks for the help so far! John Hendrickx --- Thomas Lumley <[EMAIL PROTECTED]> wrote: > On Thu, 30 Jan 2003, John Hendrickx wrote: > > > The only problem though is the last step, specifying a list of > varying > > variables. It should be possible to generate this from > "names(dset)" > > but I can't get it right. "as.list(rep(names(dset),2))" produces > a > > list with four elements rather than a list with 2 components each > > containing two elements. "dim()" gives a matrix as a result. > Could > > someone show me how to create > "list(x1=c("X1","X1"),x2=c("X2","X2"))" > > from "names(dset)"? > > lapply(names(dset),rep,2) > gives > [[1]] > [1] "X1" "X1" > > [[2]] > [1] "X2" "X2" > > -thomas > > ______________________________________________ > [EMAIL PROTECTED] mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help