> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of rami jiossy
> Sent: Monday, August 24, 2009 12:01 PM
> To: R-Help
> Subject: [R] create list entry from variable
>
>
> Hi;
>
> assume i<-10
>
> how can i create a list having key=10 and value=11
>
> list(i=11) generates a list with
>
> 'i'
> [1] 11
>
> and not
>
> 10
> [1] 11
>
> any help?
You can use [[<- with a character argument for the key
> myList<-list()
> i<-"10"
> myList[[i]] <- 11
> myList
$`10`
[1] 11
If you use an integer argument, as in,
myList[[10]] <- 11
then 11 becomes the 10'th element of myList, not the
element named '10'.
myList[[i]] <- NULL
will remove the element.
Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com
>
> Thanks
>
> _________________________________________________________________
>
> Facebook.
>
> :ON:WL:en-US:SI_SB_facebook:082009
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>