[R] How can I put the object name in list

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Tue Nov 15 13:10:20 CET 2005


Muhammad Subianto wrote:

>  > Hair <- c("Black","Brown","Red","Blond")
>  > Eye <- c("Brown","Blue","Hazel","Green")
>  > Sex <- c("Male","Female")
>  >
>  > HEC.list <- list(Hair,Eye,Sex)
>  > HEC.list
> [[1]]
> [1] "Black" "Brown" "Red"   "Blond"
> 
> [[2]]
> [1] "Brown" "Blue"  "Hazel" "Green"
> 
> [[3]]
> [1] "Male"   "Female"

After constructing the list you can give it names this way:

  > names(HEC.list)=c("Hair","Eye","Sex")

Or do it at the time you create the list:

  > HEC.list <- list(Hair=Hair,Eye=Eye,Sex=Sex)

Barry




More information about the R-help mailing list