Re: [Rd] as.Date nuance

2007-03-26 Thread Vladimir Dergachev
On Saturday 24 March 2007 12:12 pm, Gabor Grothendieck wrote: > It matches in the sense of grep or regexpr > > grep("a", "ab") > 0 > regexpr("a", "ab") > 0 > > Try this: > > x <- c("2006-01-01error", "2006-01-01") > as.Date(x, "%Y-%m-%d") + ifelse(regexpr("^-..-..$", x) > 0, 0, NA) > Well, sti

Re: [Rd] as.Date nuance

2007-03-24 Thread Gabor Grothendieck
It matches in the sense of grep or regexpr grep("a", "ab") > 0 regexpr("a", "ab") > 0 Try this: x <- c("2006-01-01error", "2006-01-01") as.Date(x, "%Y-%m-%d") + ifelse(regexpr("^-..-..$", x) > 0, 0, NA) On 3/24/07, Vladimir Dergachev <[EMAIL PROTECTED]> wrote: > On Saturday 24 March 2007

Re: [Rd] as.Date nuance

2007-03-24 Thread Vladimir Dergachev
On Saturday 24 March 2007 6:21 am, Prof Brian Ripley wrote: > This is how strptime() works: it processes the input to match the format. Except that the format does not match the string - there are leftover characters. Even by R's own definition: > match("a", "ab") [1] NA as, of course, is reaso

Re: [Rd] as.Date nuance

2007-03-24 Thread Prof Brian Ripley
This is how strptime() works: it processes the input to match the format. On Fri, 23 Mar 2007, Vladimir Dergachev wrote: > I have encountered a nuance in as.Date() behaviour that is not altogether > obvious - not sure whether this is intended or not: > >> as.Date("2001-01-01error") > [1] "2001-0

[Rd] as.Date nuance

2007-03-23 Thread Vladimir Dergachev
Hi, I have encountered a nuance in as.Date() behaviour that is not altogether obvious - not sure whether this is intended or not: > as.Date("2001-01-01error") [1] "2001-01-01" I.e. it ignores the rest of the characters. This happens both in 2.3.1 and 2.4.1 versions. This also happens wit