[R] Merging 2 files with different timestamp

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon May 23 20:16:07 CEST 2016


You have by now seen some other responses on the list. Keeping the list 
included will insure you continue to get mulitple eyes looking at the 
problem and will benefit others trying to use the answers.

Two comments:

1) Your first format includes a specification for seconds. If that is 
nonzero at any point you could have difficulty aligning that data with the 
second format. In some cases this may be desirable, in other cases you may 
prefer to use some kind of "nearest minute" calculation such as 
trunc.POSIXt or round.POSIXt might yield. If you do so, be aware that 
those functions always return POSIXlt, and efficient computation is 
usually obtained with POSIXct, so convert if you have to.

2) It is not necessary to convert back to character as Jim Holtman 
suggests in order to merge the data... working with POSIXct data type 
directly will be more efficient. I would warn against using POSIXlt for 
merging, though, for poor efficiency reasons.

On Mon, 23 May 2016, Bhaskar Mitra wrote:

> Dear Jeff,
> Time zone is UTC. No, daylight savings time does not apply.
> 
> regards,
> bhaskar
> 
> On Sun, May 22, 2016 at 4:10 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
> wrote:
>       What time zone are these data in? Does daylight savings
>       adjustment apply?
>       --
>       Sent from my phone. Please excuse my brevity.
>
>       On May 22, 2016 9:48:08 AM PDT, Bhaskar Mitra
>       <bhaskar.kolkata at gmail.com> wrote:
> 
> Hello,
> My apologies for the earlier posting. There was an error with regard to my
> query :
> I am trying to merge two text files by using the timestamp
> header for both the files:
> The first file has the following format for the timestamp:"27-Dec-12 23H
> 30M 0S"
> Timestamp for the second file : 2012-12-27 2330.
> I am having problems by converting from one timestamp format to another.
> Any suggestions/help in this regard?
> regards,
> On Sun, May 22, 2016 at 12:40 PM, Bhaskar Mitra <bhaskar.kolkata at gmail.com>
> wrote:
>  Hello, I am trying to merge two text files by using the timestamp
>  header for both the files:
>  The first file has the following format for the timestamp:"2012-01-01
>  23:30:00 UTC"
>  Timestamp for the second file : 2012-01-01 2330.
>  I am having problems by converting from one timestamp format to another.
>  Any suggestions/help in this regard?
>  regards,
>  [[alternative HTML version deleted]]
> ____________________________________________________________________________
> 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.
> 
> 
> 
>

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------


More information about the R-help mailing list