Re: [Rd] Field initialization order bug?

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Tue, 17 Jul 2007 14:34:02 +0200

Prof Brian Ripley wrote:
> On Mon, 16 Jul 2007, Daniel Wilhelm wrote:
>
>
>> I believe that I may have found a bug in R. The top code sample gives
>>
>
> You have 'merely' found a bug in your understanding. What type did you
> expect 'a' to be? If you expected a list, that is not what happens in the
> first example, and you need
>
> a <- list()
>
> or, better,
>
> a <- vector("list", 2)
>
>
To be precise, you need

a <- vector("list", 2) ; names(a) <- c("field1", "field2")

or you end up with a 4-element list.

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 17 Jul 2007 - 12:48:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 Jul 2007 - 20:38:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.