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
savings' ('summer') and 'standard' ('winter') each spring and fall.

You can attach your time to a fake date and arrange to only print the
time portion, but since you have a date, use it.




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jun 8, 2016 at 10:40 PM, Ek Esawi  wrote:

> 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
> package; the latter is too long and I did not have time to experiment with
> it. I think the lubridate package might be useful for this; but again I did
> not want to get into many packages. So I tried chron using the times
> function that produced what I want. Indeed as Don said, I could not figure
> out how to use it in a read.table; so I had already decided to do what Don
> suggested which is read them as character then convert them one vector at a
> time to time class.
>
>
>
> What do I need this stuff for? Well, I published a paper 6 months ago where
> I had to deal with time data and needed to convert and manipulate time
> data. I did all that work in Excel and it took too long; so I want to learn
> R for future research and use the same data using R.
>
>
>
> I agree with Jeff’s comments. 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.
>
>
>
> Thanks againEK
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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.
>

[[alternative HTML version deleted]]

__
R-help@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.

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
package; the latter is too long and I did not have time to experiment with
it. I think the lubridate package might be useful for this; but again I did
not want to get into many packages. So I tried chron using the times
function that produced what I want. Indeed as Don said, I could not figure
out how to use it in a read.table; so I had already decided to do what Don
suggested which is read them as character then convert them one vector at a
time to time class.



What do I need this stuff for? Well, I published a paper 6 months ago where
I had to deal with time data and needed to convert and manipulate time
data. I did all that work in Excel and it took too long; so I want to learn
R for future research and use the same data using R.



I agree with Jeff’s comments. 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.



Thanks againEK

[[alternative HTML version deleted]]

__
R-help@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.

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 difftime 
values.

It is also possible to let the conversion to POSIXct pick "today" by default, 
but you can sometimes get into trouble if you subtract out "today" on a 
different day, so I wouldn't recommend it. 

You also may encounter difficulty with daylight savings in this process... but 
that usually requires knowing a bit more about your data, and if you are 
already working with time only data you may not be able to fix such problems 
anyway. 
-- 
Sent from my phone. Please excuse my brevity.

On June 8, 2016 10:20:38 AM PDT, "MacQueen, Don"  wrote:
>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 into R as character strings, and then convert them (it would take
>only a few extra lines of code). How you convert them depends on the
>next
>question, which is:
>
>What do you need to do with those times?
>
>For example, are T1 and T2 the times associated with two events that
>both
>occurred on the specified Date? If that is the case, I would probably
>form
>two POSIXct variables by combining the Date with T1 and the Date with
>T2.
>Or, do you just need to be able to sort your data by T1, or by T2? Or
>do
>you need to calculate the time differences (such as T2-T1) to get the
>number of minutes between those two times?
>
>-Don
>
>-- 
>Don MacQueen
>
>Lawrence Livermore National Laboratory
>7000 East Ave., L-627
>Livermore, CA 94550
>925-423-1062
>
>
>
>
>
>On 6/5/16, 5:53 AM, "R-help on behalf of Ek Esawi"
> wrote:
>
>>Hi All--
>>
>>
>>
>>I am relatively new to R. I am reading a csv file via read.table
>(MyFile).
>>The data types in the file are date, string, integer, and time. I was
>able
>>to read all the data and manipulated correctly except time, e.g.,
>12:30. I
>>used as.Date to convert date and string and integer were easily done.
>I
>>could not figure out how to convert the time data correctly. I tried
>chron
>>but w/o success and I read that POSIXlt and POSIXct work only for date
>and
>>time (e.g. 01/02/1999, 12:30:20). I did not try the lubridate package.
>Is
>>there a way to read time data without date attached to it like mine?
>>
>>
>>
>>I am grateful for any help and thanks in advance‹EKE
>>
>>
>>
>>Here is an example of my data when read into R via read.table
>>
>>
>>
>>AA  Date Name T1  T2
>>N1
>>
>>1  312171  7/1/1995   OF  13:37  1:43
>123
>>
>>  [[alternative HTML version deleted]]
>>
>>__
>>R-help@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.
>
>__
>R-help@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.

[[alternative HTML version deleted]]

__
R-help@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.

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 into R as character strings, and then convert them (it would take
only a few extra lines of code). How you convert them depends on the next
question, which is:

What do you need to do with those times?

For example, are T1 and T2 the times associated with two events that both
occurred on the specified Date? If that is the case, I would probably form
two POSIXct variables by combining the Date with T1 and the Date with T2.
Or, do you just need to be able to sort your data by T1, or by T2? Or do
you need to calculate the time differences (such as T2-T1) to get the
number of minutes between those two times?

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 6/5/16, 5:53 AM, "R-help on behalf of Ek Esawi"
 wrote:

>Hi All--
>
>
>
>I am relatively new to R. I am reading a csv file via read.table (MyFile).
>The data types in the file are date, string, integer, and time. I was able
>to read all the data and manipulated correctly except time, e.g., 12:30. I
>used as.Date to convert date and string and integer were easily done. I
>could not figure out how to convert the time data correctly. I tried chron
>but w/o success and I read that POSIXlt and POSIXct work only for date and
>time (e.g. 01/02/1999, 12:30:20). I did not try the lubridate package. Is
>there a way to read time data without date attached to it like mine?
>
>
>
>I am grateful for any help and thanks in advance‹EKE
>
>
>
>Here is an example of my data when read into R via read.table
>
>
>
>AA  Date Name T1  T2
>N1
>
>1  312171  7/1/1995   OF  13:37  1:43 123
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@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.

__
R-help@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.


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

2016-06-08 Thread PIKAL Petr
Hi

I am rather confused. If you have data in some external file, (csv, txt, tab 
delimited), you can read it by corresponding read.* command to data.frame 
object. I did not know about conversion to POSIX directly by reading an object 
(it does not mean there is none).

After you read your data you can concatenate some variables to a character by 
paste.

e.g.

tmp <- paste("7/1/1995", "13:37", sep=" ")
or
dat1 <- paste(Date, Time, sep=" ")

and you can use properly formated strptime to convert values to POSIX

strptime(tmp, format="%d/%m/%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
>
> 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 convert the time
> columns to POSIXlt or chron in the read.table statement. I was able to use
> as.Date in the read.table to convert the dates.
>
>
> Thanks-EK
>
>
>
>O Date  Name Time Inter Dura  Prep Hht
>  Pred
>
> 1 312171  7/1/1995 Old-1   13:37 1:43 4:42   13:16   162
> 13:19
>
> 2 358237 5/25/1993Old-2   12:22 1:31 4:16   12:03   160
> 12:13
>
> 3 339971 7/17/1994Old-3   15:54 1:23 4:36   15:43   160
>  15:51
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney i

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 dates w/o time and i was able
to produce a function that can be included in colClasses to reformat date
correctly and convert them to class date. i even stumbled on a way to
convert my time data to time class via the chron package. Here is what i
did  times(paste0(t1, ":00")) where t1 is the first element of the column
named Time. The problem i have now is how to incorporate this
function/command into the colClasses in read.table so that i don't have to
convert every entry in each column, one at a time.

Thank you for the help. EK

[[alternative HTML version deleted]]

__
R-help@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.


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: install.packages("Ecfun", 
repos="http://R-Forge.R-project.org";).  If I recall correctly, the 
R-Forge version works the same as the CRAN version for POSIX but fixes a 
subtle bug for Dates.



  Hope this helps.
  Spencer Graves


p.s.  If anyone knows a better way to do this, I'm interested.


On 6/7/2016 5:26 PM, Ek Esawi wrote:

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 convert the
time columns to POSIXlt or chron in the read.table statement. I was able to
use as.Date in the read.table to convert the dates.


Thanks-EK



O Date  Name Time Inter Dura  Prep Hht
  Pred

1 312171  7/1/1995 Old-1   13:37 1:43 4:42   13:16   162
13:19

2 358237 5/25/1993Old-2   12:22 1:31 4:16   12:03   160
12:13

3 339971 7/17/1994Old-3   15:54 1:23 4:36   15:43   160
  15:51

[[alternative HTML version deleted]]

__
R-help@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.


__
R-help@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.


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 convert the
time columns to POSIXlt or chron in the read.table statement. I was able to
use as.Date in the read.table to convert the dates.


Thanks-EK



   O Date  Name Time Inter Dura  Prep Hht
 Pred

1 312171  7/1/1995 Old-1   13:37 1:43 4:42   13:16   162
13:19

2 358237 5/25/1993Old-2   12:22 1:31 4:16   12:03   160
12:13

3 339971 7/17/1994Old-3   15:54 1:23 4:36   15:43   160
 15:51

[[alternative HTML version deleted]]

__
R-help@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.


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 csv file via read.table (MyFile).
> The data types in the file are date, string, integer, and time. I was able to
> read all the data and manipulated correctly except time, e.g., 12:30. I used
> as.Date to convert date and string and integer were easily done. I could not
> figure out how to convert the time data correctly. I tried chron but w/o
> success and I read that POSIXlt and POSIXct work only for date and time (e.g.

If you used strptime for converting your datae/time value you can tune it by 
format to be able to read differently formated data.


> strptime("01/02/1999, 12:30:20", format="%d/%m/%Y, %H:%M:%S")
[1] "1999-02-01 12:30:20 CET"
> strptime("01/02/1999, 12:30", format="%d/%m/%Y, %H:%M")
[1] "1999-02-01 12:30:00 CET"
> strptime("01/02/1999, 12", format="%d/%m/%Y, %H")
[1] "1999-02-01 12:00:00 CET"
>

> str(strptime("01/02/1999, 12", format="%d/%m/%Y, %H"))
 POSIXlt[1:1], format: "1999-02-01 12:00:00"
>

Regards
Petr


> 01/02/1999, 12:30:20). I did not try the lubridate package. Is there a way to
> read time data without date attached to it like mine?
>
>
>
> I am grateful for any help and thanks in advance—EKE
>
>
>
> Here is an example of my data when read into R via read.table
>
>
>
> AA  Date Name T1  T2
> N1
>
> 1  312171  7/1/1995   OF  13:37  1:43 123
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expres

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 colclasses so that the whole table is converted to correct time
format which later can be manipulated


Thanks again--EK.

[[alternative HTML version deleted]]

__
R-help@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.


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 Esawi  wrote:
> Hi All--
>
>
>
> I am relatively new to R. I am reading a csv file via read.table (MyFile).
> The data types in the file are date, string, integer, and time. I was able
> to read all the data and manipulated correctly except time, e.g., 12:30. I
> used as.Date to convert date and string and integer were easily done. I
> could not figure out how to convert the time data correctly. I tried chron
> but w/o success and I read that POSIXlt and POSIXct work only for date and
> time (e.g. 01/02/1999, 12:30:20). I did not try the lubridate package. Is
> there a way to read time data without date attached to it like mine?
>
>
>
> I am grateful for any help and thanks in advance—EKE
>
>
>
> Here is an example of my data when read into R via read.table
>
>
>
> AA  Date Name T1  T2
> N1
>
> 1  312171  7/1/1995   OF  13:37  1:43 123
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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.

__
R-help@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.

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

2016-06-05 Thread Ek Esawi
Hi All--



I am relatively new to R. I am reading a csv file via read.table (MyFile).
The data types in the file are date, string, integer, and time. I was able
to read all the data and manipulated correctly except time, e.g., 12:30. I
used as.Date to convert date and string and integer were easily done. I
could not figure out how to convert the time data correctly. I tried chron
but w/o success and I read that POSIXlt and POSIXct work only for date and
time (e.g. 01/02/1999, 12:30:20). I did not try the lubridate package. Is
there a way to read time data without date attached to it like mine?



I am grateful for any help and thanks in advance—EKE



Here is an example of my data when read into R via read.table



AA  Date Name T1  T2
N1

1  312171  7/1/1995   OF  13:37  1:43 123

[[alternative HTML version deleted]]

__
R-help@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.