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

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Tue Nov 15 13:12:56 CET 2005



Muhammad Subianto wrote:
> Dear R-helpers,
> How can I put the object name in list.
> 
>  > 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"
>  >
> 
> I expect the result like this,
> 
> $Hair
> [1] "Black" "Brown" "Red"   "Blond"
> 
> $Eye
> [1] "Brown" "Blue"  "Hazel" "Green"
> 
> $Sex
> [1] "Male"   "Female"
> 
> Best, Muhammad Subianto
> 

Try:

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

This is described in the Details section of ?list.

--sundar




More information about the R-help mailing list