From richard_raubertas at merck.com  Fri Jun 28 16:29:38 2013
From: richard_raubertas at merck.com (Raubertas, Richard)
Date: Fri, 28 Jun 2013 10:29:38 -0400
Subject: [Rd] 'modifyList' drops (not adds) NULL components
In-Reply-To: <CADfFDC5H8LBnrbxwQGN_nuv9UnacRVRo1xagp=aDTmS_zwHEBg@mail.gmail.com>
References: <1D693EC430D9BA40A64CB59875BED8CF013447FF8464@USCTMXP51004.merck.com>
	<CADfFDC5H8LBnrbxwQGN_nuv9UnacRVRo1xagp=aDTmS_zwHEBg@mail.gmail.com>
Message-ID: <1D693EC430D9BA40A64CB59875BED8CF01344807A1D5@USCTMXP51004.merck.com>

See response inline below.

> -----Original Message-----
> From: Deepayan Sarkar [mailto:deepayan.sarkar at gmail.com]
> Sent: Friday, June 28, 2013 7:17 AM
> To: Raubertas, Richard
> Cc: R-devel at r-project.org
> Subject: Re: [Rd] 'modifyList' drops (not adds) NULL components
> 
> On Thu, Jun 27, 2013 at 10:59 PM, Raubertas, Richard
> <richard_raubertas at merck.com> wrote:
> > Dear list,
> >
> > Utils::modifyList() drops NULL components in its second argument, instead
> of adding them to the first argument.  Compare:
> >> modifyList(x=list(A=1), val=list(B=2, C=3))
> > $A
> > [1] 1
> >
> > $B
> > [1] 2
> >
> > $C
> > [1] 3
> >
> >> modifyList(x=list(A=1), val=list(B=NULL, C=3))
> > $A
> > [1] 1
> >
> > $C
> > [1] 3
> >
> > To me this seems inconsistent with the documentation ("Elements in 'val'
> which are missing from 'x' are added to 'x'."),
> 
> Agreed.
> 
> > and also with how I'd want the function to behave.
> 
> Note that you still get
> 
> > foo <- modifyList(x=list(A=1), val=list(B=NULL, C=3))
> > foo$B
> NULL
> 
> So is there a specific reason you want the NULL elements to be
> explicitly listed?
> 
> -Deepayan

Yes, definitely.  Although 'foo$B' gives the same result, 'length(foo)' or 'names(foo)' do not.  Basically, the object 'foo', considered as a whole, is very different in the two cases, and this was a problem in the code I was writing.

Richard
> 
> >
> >> sessionInfo()
> > R version 3.0.1 Patched (2013-06-16 r62969)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> >
> > locale:
> > [1] LC_COLLATE=English_United States.1252
> > [2] LC_CTYPE=English_United States.1252
> > [3] LC_MONETARY=English_United States.1252
> > [4] LC_NUMERIC=C
> > [5] LC_TIME=English_United States.1252
> >
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> >
> > Richard Raubertas
> > Merck & Co.
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates Direct contact information
for affiliates is available at 
http://www.merck.com/contact/contacts.html) that may be confidential,
proprietary copyrighted and/or legally privileged. It is intended solely
for the use of the individual or entity named on this message. If you are
not the intended recipient, and have received this message in error,
please notify us immediately by reply e-mail and then delete it from 
your system.


[Rd] 'modifyList' drops (not adds) NULL components
Raubertas, Richard