[R] Named components in a list
William Dunlap
wdunlap at tibco.com
Thu Nov 10 21:27:11 CET 2011
R may surprise you here, but it is self-consistent.
What would you expect from the following?
> x <- c(one=1,two=2,3,four=4)
> x
one two four
1 2 3 4
> x[c("two", "five")] <- c(twentytwo=22, fiftyfive=55)
> x
one two four five
1 22 3 4 55
'x[c(2,5)] <- ...' must act the same.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of JulioSergio
> Sent: Thursday, November 10, 2011 11:51 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] Named components in a list
>
> Sarah Goslee <sarah.goslee <at> gmail.com> writes:
>
> >
> > Hi,
> >
>
> > You probably want:
> > L["NewName"] <- "something"
> > or one of the many potential variants.
> >
>
> Thanks, Sara,
> That works!
> However, following the idea that the syntactic notation L[i] means
> a sublist of L, again the syntactic notation
>
> L[i] <- list(Name=Value)
>
> should mean that the sublist is now assigned the list with the a unique named
> element. So I insist this is either a bug or an inconsistency of the language.
>
> Thanks again,
>
> Sergio.
>
> ______________________________________________
> 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.
More information about the R-help
mailing list