From pdalgd at gmail.com  Thu Aug 21 09:28:34 2014
From: pdalgd at gmail.com (peter dalgaard)
Date: Thu, 21 Aug 2014 09:28:34 +0200
Subject: [Rd] as.Date.character suggestion
In-Reply-To: <CADwqtCNQ8JnB=5-FKcSWc6XYujWbvSALLjUnOc7su4RqR6RHWw@mail.gmail.com>
References: <CA+hbrhUZnZMMPL9gfK3rYzR7z9K8tEwsyFC2VOa_y0Lu254bZQ@mail.gmail.com>
	<53F5029C.3080909@gmail.com>
	<CA+hbrhUaZgCBjfwhT7Nnu9g3Xjsub_EdHSvmz5KksSFwgNS_4A@mail.gmail.com>
	<CADwqtCMLWqOJ5KF4HWdF63iOpMwafDjA1bxTaPpJHe6+2Q2jvA@mail.gmail.com>
	<CA+hbrhUr9jV8Jxb5Bjo4SXC-eriY7or39JmOc5XY-X=Ph5C38A@mail.gmail.com>
	<CADwqtCNQ8JnB=5-FKcSWc6XYujWbvSALLjUnOc7su4RqR6RHWw@mail.gmail.com>
Message-ID: <FAF4F39F-4B65-4AE5-8A39-7558624BEEE3@gmail.com>


On 21 Aug 2014, at 02:21 , Gabriel Becker <gmbecker at ucdavis.edu> wrote:

> Ah, my mistake, I read too fast. (My code is also wrong, embarassingly).
> 
> It seems like it's behavior when you pass it "" is simply a bug, then.
> 
> Sorry for the noise,
> 
> ~G
> 

It's not a bug, it's just that you are at the mercy of strptime() if you do specify a format. If the format doesn't contain a conversion for some component, you get the value corresponding to the current date and leftover characters are just ignored, e.g.

> strptime("1-1foo","%m-%d")
[1] "2014-01-01"

and the extreme case is that a "" format gives current date, whatever the input. On Mac OSX Mavericks anyway --- this stuff is system-dependent.

So I think Peter Langfelder is absolutely right, remove the default, which is never used anyway, and possibly update the documentation with a more direct reference to strptime(). This should have near-zero effect on the semantics. 

Peter D.

> 
> 
> 
> On Wed, Aug 20, 2014 at 4:59 PM, Peter Langfelder <
> peter.langfelder at gmail.com> wrote:
> 
>> On Wed, Aug 20, 2014 at 4:52 PM, Gabriel Becker <gmbecker at ucdavis.edu>
>> wrote:
>>> Could do both to preserve bc...
>>> 
>>> if(missing(format) || !nchar(format))
>>> 
>> 
>> No, the problem is that the function behaves differently when format
>> is missing than when it equals its default. Removing this difference
>> necessarily changes behaviour and hence (at least in principle) breaks
>> backward compatibility.
>> 
>> Peter
>> 
> 
> 
> 
> -- 
> Gabriel Becker
> Graduate Student
> Statistics Department
> University of California, Davis
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] as.Date.character suggestion
peter dalgaard