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
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
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 = c("Black","Brown","Red","Blond"), Eye = c("Brown","Blue","Hazel","Green"), Sex = c("Male","Female")) Best, Jim> > > > 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 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html-- James W. MacDonald University of Michigan Affymetrix and cDNA Microarray Core 1500 E Medical Center Drive Ann Arbor MI 48109 734-647-5623 ********************************************************** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues.
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
Yes, thanks you very much. Regards, Muhammad Subianto > HEC.list <- list(Hair=Hair,Eye=Eye,Sex=Sex) > ?list On this day 15/11/2005 12:54 PM, 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 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >