[R] multinomial conditional logit models

Thomas Lumley tlumley at u.washington.edu
Thu Jan 30 17:58:58 CET 2003


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




More information about the R-help mailing list