Also note the behavior is the same for a non-list vector:
> c(b=1)[c('a','b')]
<NA> b
NA 1
but differs for a data frame:
> data.frame(b=1)[c('a','b')]
Error in `[.data.frame`(data.frame(b = 1), c("a", "b")) :
undefined columns selected
On Fri, Nov 28, 2008 at 2:03 PM, Vadim Ogranovich
<[EMAIL PROTECTED]> wrote:
> Dear R-devel,
>
> When a character vector is used to subscript a list and when some of the
> subscripts are not present in the list names R returns NULL for those
> subscripts and generate NA names for each of them:
>
>> list(b=1)[c('a','b')]
> $<NA> <<-- generated name
> NULL
> $b
> [1] 1
>
>
> Wouldn't it be more intuitive to use the subscript name rather than to
> generate an NA? Something like this (not real result):
>> list(b=1)[c('a','b')]
> $a <<-- more intuitive name
> NULL
> $b
> [1] 1
>
>
>> version
> _
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 7.1
> year 2008
> month 06
> day 23
> svn rev 45970
> language R
> version.string R version 2.7.1 (2008-06-23)
>>
>
>
> Thanks,
> Vadim
>
> ________________________________
> Note: This email is for the confidential use of the named addressee(s) only
> and may contain proprietary, confidential or privileged information. If you
> are not the intended recipient, you are hereby notified that any review,
> dissemination or copying of this email is strictly prohibited, and to please
> notify the sender immediately and destroy this email and any attachments.
> Email transmission cannot be guaranteed to be secure or error-free. Jump
> Trading, therefore, does not make any guarantees as to the completeness or
> accuracy of this email or any attachments. This email is for informational
> purposes only and does not constitute a recommendation, offer, request or
> solicitation of any kind to buy, sell, subscribe, redeem or perform any type
> of transaction of a financial product.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel