[R] Merging 2 files with different timestamp

jim holtman jholtman at gmail.com
Sun May 22 22:41:17 CEST 2016


Is this the format of a column within the two different files?  If they are
columns, here is a way of converting to a common format for merging:


> # convert to POSIXct
> date1 <- as.POSIXct("27-Dec-12 23H 30M 0S", format = "%d-%b-%y %HH %MM
%SS")
> date2 <- as.POSIXct('2012-12-27 2330', format = "%Y-%m-%d %H%M")
>
> # now convert to a common character format for merging
> date1_new <- format(date1, "%Y%m%d%H%M%S")
> date2_new <- format(date2, "%Y%m%d%H%M%S")
> date1_new
[1] "20121227233000"
> date2_new
[1] "20121227233000"



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sun, May 22, 2016 at 12:48 PM, 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list