Re: [R] Reading and converting time data via read.table

2016-06-09 Thread William Dunlap via R-help
>In fact, I learned most of them the hard way >by trial and error and realized that it’s difficult to separate time and >date using POSIXct and POSIXlt. It is difficult to separate time from data in real life as well. The most common problem is when your time zone switches between 'daylight savin

Re: [R] Reading and converting time data via read.table

2016-06-09 Thread Ek Esawi
Thank you Jeff and Don. As I stated on my original posting that I am relatively new to R. After a few weeks of searching and reading I have come to the same point that Don made which is base R doesn’t have a class for time only. I explored the chron and lubridate packages and even looked at Ecfun p

Re: [R] Reading and converting time data via read.table

2016-06-08 Thread Jeff Newmiller
The canonical way to store times is as difftime vectors. However, there is no simple way to import e.g. HH:MM data directly into such vectors, so you need to embed such times into a longer string that includes a fixed date. After conversion to POSIXct you can subtract the fixed date to get the

Re: [R] Reading and converting time data via read.table

2016-06-08 Thread MacQueen, Don
As far as I know, base R does not have a class for storing times that are not associated with a date, and recognizing that they are times. That being the case, I don't think there is a way to convert them to some sort of time class while reading them into R using read.table(). I would read them int

Re: [R] Reading and converting time data via read.table

2016-06-08 Thread PIKAL Petr
/%Y %H:%M") Regards Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ek Esawi > Sent: Wednesday, June 8, 2016 12:26 AM > To: r-help@r-project.org > Subject: Re: [R] Reading and converting time data via read.table > > Than

Re: [R] Reading and converting time data via read.table

2016-06-07 Thread Ek Esawi
Thanks for the responses i received from David and Spencer. As for the package Ecfun, i looked at it briefly, but it's long and i am new to R; so this just adds to my confusion. David suggested the sub function which i will try and see what i get.i s As i said earlier i have no problems reading da

Re: [R] Reading and converting time data via read.table

2016-06-07 Thread Spencer Graves
Have you considered asNumericDF in the Ecfun package? This can convert to a date-time column into POSIXct -- not POSIXlt -- using the POSIX argument to identify the POSIX columns and format to provide the "format" argument for as.POSIXct. I suggest you try the R-Forge version: in

Re: [R] Reading and converting time data via read.table

2016-06-07 Thread Ek Esawi
Thanks Petr! I am still unable to come up with a conversion formula/trick to convert my time data to POSIXlt which then can be used in read.table. Below are again a few lines from my file. Since as you see there are several columns of time data ONLY (no date), I am hoping that there is a way to

Re: [R] Reading and converting time data via read.table

2016-06-06 Thread PIKAL Petr
Hi > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ek Esawi > Sent: Sunday, June 5, 2016 2:54 PM > To: r-help@r-project.org > Subject: [R] Reading and converting time data via read.table > > Hi All-- > > > > I am relatively new to R. I am reading a cs

Re: [R] Reading and converting time data via read.table

2016-06-05 Thread Ek Esawi
Thanks Jim! The problem is not date data. The problem is time. I figured out that I can use chron library and then use this expression times(paste0(t2, ":00")) because my time data are not h:m:s, only h;m. The problem I am trying to figure out is how to implement [times(paste0(t2, ":00"))] on c

Re: [R] Reading and converting time data via read.table

2016-06-05 Thread Jim Lemon
Hi EKE, Your problem may be that the date strings are being read as a factor. Try using stringsAsFactors=FALSE when you read the data in. Another way is to convert your dates to strings when passing to as.Date: as.Date(as.character(mydf$Date),"%m/%d/%Y") Jim On Sun, Jun 5, 2016 at 10:53 PM, Ek