On Fri, 20 Jul 2018, William Dunlap wrote:> The problem occurs because no commonly used format works on all your date > strings. If you give as.POSIXlt the format you want to use then items that > don't match the format will be treated as NA's. Use is.na() to find them.Bill, No NAs found using both is.na() and scrolling through the source file. That's why I asked for help: I saw nothing different in the dates or times. Regards, Rich
Hi Rich, This may not be the most efficient but it will identify the offenders.> foo <- paste(wy2016$date, wy2016$time)) > uu <- sapply(1:length(foo),function(i) { a <- try(as.POSIXct(foo[i]),silent=TRUE) "POSIXct" %in% class(a) })> which(!uu)HTH, Eric On Fri, Jul 20, 2018 at 9:58 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:> On Fri, 20 Jul 2018, William Dunlap wrote: > > The problem occurs because no commonly used format works on all your date >> strings. If you give as.POSIXlt the format you want to use then items that >> don't match the format will be treated as NA's. Use is.na() to find them. >> > > Bill, > > No NAs found using both is.na() and scrolling through the source file. > That's why I asked for help: I saw nothing different in the dates or times. > > Regards, > > Rich > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posti > ng-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Which format did you use when you used is.na on the output of as.POSIXlt(strings, format=someFormat) and found none? Did the resulting dates look OK? Perhaps all is well. Note the the common American format month/day/year is not one that is tested when you don't supply a format - xx/yy/zzzz is treated as year/month/day (and it changes the time zone, presumable because US/Pacific time was not used in the year 10 CE). > as.POSIXlt("10/7/1962") [1] "0010-07-19 LMT" > as.POSIXlt("3/17/1962") Error in as.POSIXlt.character("3/17/1962") : character string is not in a standard unambiguous format Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Jul 20, 2018 at 11:58 AM, Rich Shepard <rshepard at appl-ecosys.com> wrote:> On Fri, 20 Jul 2018, William Dunlap wrote: > > The problem occurs because no commonly used format works on all your date >> strings. If you give as.POSIXlt the format you want to use then items that >> don't match the format will be treated as NA's. Use is.na() to find them. >> > > Bill, > > No NAs found using both is.na() and scrolling through the source file. > That's why I asked for help: I saw nothing different in the dates or times. > > Regards, > > > Rich > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posti > ng-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
> On Jul 20, 2018, at 11:58 AM, Rich Shepard <rshepard at appl-ecosys.com> wrote: > > On Fri, 20 Jul 2018, William Dunlap wrote: > >> The problem occurs because no commonly used format works on all your date >> strings. If you give as.POSIXlt the format you want to use then items that >> don't match the format will be treated as NA's. Use is.na() to find them. > > Bill, > > No NAs found using both is.na() and scrolling through the source file. > That's why I asked for help: I saw nothing different in the dates or times. > > Regards, > > RichI don't think you read Bill's message properly. He was not saying that there were NA's; he was telling you to use a format specification in your as.POSIXct call and the the result of that call would have NA's. wy2016$dt_time <- with( wy2016, as.POSIXct( paste( date, time ) , format= "%Y-%m-%d %H:%M") ) David.> > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law
On Fri, 20 Jul 2018, William Dunlap wrote:> Which format did you use when you used is.na on the output of > as.POSIXlt(strings, format=someFormat) > and found none? Did the resulting dates look OK? Perhaps > all is well.Bill, All dates here are kept as yyyy-mm-dd. And each dataframe row has this format: 2015-10-01,00:00,90.6689 2015-10-01,01:00,90.6506 2015-10-01,02:00,90.6719 2015-10-01,03:00,90.6506 Thanks, Rich
On Fri, 20 Jul 2018, David Winsemius wrote:> I don't think you read Bill's message properly.David, Obviously not.> He was not saying that there were NA's; he was telling you to use a format > specification in your as.POSIXct call and the the result of that call > would have NA's. > > wy2016$dt_time <- with( wy2016, as.POSIXct( paste( date, time ) , format= "%Y-%m-%d %H:%M") )Thank you. This found 24 TRUEs; now to find them in the file. Thanks, Rich
On Fri, 20 Jul 2018, Eric Berger wrote:> This may not be the most efficient but it will identify the offenders. > >> foo <- paste(wy2016$date, wy2016$time)) >> uu <- sapply(1:length(foo), > function(i) { a <- try(as.POSIXct(foo[i]),silent=TRUE) > "POSIXct" %in% class(a) }) >> which(!uu)Eric, Thank you. Now I know there are NAs there this should help me find them. Regards, Rich
On Fri, 20 Jul 2018, David Winsemius wrote:> wy2016$dt_time <- with( wy2016, as.POSIXct( paste( date, time ) , format> "%Y-%m-%d %H:%M") )David/Bill/Eric: Thank you all. I found the typos which covered a single day toward the end of the dataframe. Carpe weekend, Rich