Re: [R] Checking for invalid dates: Code works but needs improvement

2012-02-04 Thread Paul Miller
Hi David and Rui, Sorry to be so slow in replying. Thank you both for pointing out that the problem with my code was that I was using comparison operators on mixed data types. This is something I'll have to be more careful about in the future. In an earlier email, David talked about how R can

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-02-01 Thread Paul Miller
Hi Marc, That the code I wrote initially is over engineered is certainly possible. Of course, Rui's solution is a reworking of that code. If starting from scratch, Rui likely would have done something quite different. I focused on Rui's code because it was complete and was a clear improvement

[R] Checking for invalid dates: Code works but needs improvement

2012-01-30 Thread Paul Miller
Hi Rui, Marc, and Gabor, Thanks for your replies to my question. All were helpful and it was interesting to see how different people approach various aspects of the same problem. Spent some time this weekend looking at Rui's solution, which is certainly much clearer than my own. Managed to

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-01-30 Thread David Winsemius
On Jan 30, 2012, at 8:44 AM, Paul Miller wrote: Hi Rui, Marc, and Gabor, Thanks for your replies to my question. All were helpful and it was interesting to see how different people approach various aspects of the same problem. Spent some time this weekend looking at Rui's solution,

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-01-30 Thread Marc Schwartz
On Jan 30, 2012, at 12:15 PM, David Winsemius wrote: On Jan 30, 2012, at 8:44 AM, Paul Miller wrote: Hi Rui, Marc, and Gabor, Thanks for your replies to my question. All were helpful and it was interesting to see how different people approach various aspects of the same problem.

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-01-30 Thread Marc Schwartz
On Jan 30, 2012, at 1:30 PM, Marc Schwartz wrote: On Jan 30, 2012, at 12:15 PM, David Winsemius wrote: On Jan 30, 2012, at 8:44 AM, Paul Miller wrote: Hi Rui, Marc, and Gabor, Thanks for your replies to my question. All were helpful and it was interesting to see how different

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-01-30 Thread Rui Barradas
Hello, I'm glad it helped. Error in if (any(is.na(x) M != un Y != un)) cat(Warning: Invalid date values in, : missing value where TRUE/FALSE needed Why is this happening? If the code correctly correctly handles the date 06/20/1840 without producing an error, why can't it do

[R] Checking for invalid dates: Code works but needs improvement

2012-01-26 Thread Paul Miller
To: r-help@r-project.org Subject: Re: [R] Checking for invalid dates: Code works but needs improvement Message-ID: 1327427697928-4324533.p...@n4.nabble.com Content-Type: text/plain; charset=us-ascii Hello, Point 3 is very simple, instead of 'print' use 'cat'. Unlike 'print' it allows

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-01-26 Thread Marc Schwartz
-write my code as I improve. Appreciate your help. Paul Message: 66 Date: Tue, 24 Jan 2012 09:54:57 -0800 (PST) From: Rui Barradas ruipbarra...@sapo.pt To: r-help@r-project.org Subject: Re: [R] Checking for invalid dates: Code works but needs improvement Message-ID: 1327427697928

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-01-26 Thread Gabor Grothendieck
On Tue, Jan 24, 2012 at 11:54 AM, Paul Miller pjmiller...@yahoo.com wrote: Hello Everyone, Still new to R. Wrote some code that finds and prints invalid dates (see below). This code works but I suspect it's not very good. If someone could show me a better way, I'd greatly appreciate it.

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-01-26 Thread Rui Barradas
Hello, again. I now have a more complete answer to your points. 1. It's too long. My understanding is that skilled programmers can usually or often complete tasks like this in a few lines. It's not very shorter but it's more readable. (The programmer is always suspect) 2. It's not

[R] Checking for invalid dates: Code works but needs improvement

2012-01-24 Thread Paul Miller
Hello Everyone, Still new to R. Wrote some code that finds and prints invalid dates (see below). This code works but I suspect it's not very good. If someone could show me a better way, I'd greatly appreciate it. Here is some information about what I'm trying to accomplish. My sense is that

Re: [R] Checking for invalid dates: Code works but needs improvement

2012-01-24 Thread Rui Barradas
Hello, Point 3 is very simple, instead of 'print' use 'cat'. Unlike 'print' it allows for several arguments and (very) simple formating. { cat(Error: Invalid date values in, DateNames[[i]], \n, TestDates[DateNames][[i]][TestDates$Invalid==1], \n) } Rui Barradas -- View this