Try this:

1)eval(parse(text=paste("MyList<-list(", colnames(Model)[2], "=",
Model[,colnames(Model)[2]], ")")))

2)Model[,colnames(Model)[2]]

3)MyList[[3]] <- "Teste"
   MyList[[4]] <- "Teste1"


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

On 07/11/2007, Gang Chen <[EMAIL PROTECTED]> wrote:
>
>
> I want to create a list based on the information from a data.frame,
> Model. So I tried the following:
>
> MyList <- list(colnames(Model)[2] = levels(Model$(colnames(Model)[2])))
>
> but it failed with an error:
>
> Error: unexpected '=' in "list(colnames(Model)[2] ="
>
> I have the following problems with this command line:
>
> (1) I wanted to use colnames(Model)[2] as a tag for the list:
>
> > colnames(Model)[2]
> [1] "gender"
>
> but it is not working as I intended. How to make colnames(Model)[2] a
> legitimate tag?
>
> (2) Model$gender is a column in the data.frame. However Model$
> (colnames(Model)[2]) seems not recognizable in the command line. How
> to correct this?
>
> (3) How to add more tagged items to an existing list? cbind or rbind?
>
> Thanks in advance,
> Gang
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to