Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9216739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:28:52+00:00 2026-06-18T02:28:52+00:00

Hello I have two dataframes each with a different timestamp format. DF1 is organized

  • 0

Hello I have two dataframes each with a different timestamp format. DF1 is organized as m/d/YYYY H:M and DF2 as YYYYmmdd. I would like to merge these data frames based on their timestamp by date (month, day, and year) I am not concerned about the time for the merge. When I try to merge the result is a dataframe that consists of NA in for the ts column. I think this is because the time is not matching up, whilst DF2 does not display the time, I think it is recognized as 00:00:00 and therefore the merge doesn’t work. Is there a way to ignore the time from the timestamp?

I have tried the following.

DF1 <- read.csv("DF1.csv",header=T)
DF2 <- read.csv("DF2.csv",header=T)

DF1$ts <- strptime(DF1$ts, "%m/%d/%Y %H:%M)
DF2$ts <- strptime(DF2$ts, "%Y%m%d")

DF1$ts <- as.POSIXct(DF1$ts)
DF2$ts <- as.POSIXct(DF2$ts)

try <- merge(DF1, DF2, by="ts")

#dput DF1 (sample)
DF1 <- structure(list(LENGTH = c(40, 33.6, 30, 30, 40, 43.5, 50, 40, 
62.5, 30), pLENGTH = c(0, 0.297619048, 0, 1, 0, 0, 1, 0, 0.16, 
0.666666667), LENGTH2 = c(30.7, NA, 30, NA, 25.1, 39.6, 50, 
NA, NA, NA), BURN = c(1L, NA, 1L, NA, 1L, 1L, 1L, NA, NA, 
NA), pBURN = c(0.7675, NA, 1, NA, 0.6275, 0.910344828, 1, NA, 
NA, NA), ts = structure(c(1344916800, NA, 1339819200, NA, 
1339646400, 1345003200, 1340769600, NA, NA, NA), class = c("POSIXct", 
"POSIXt"), tzone = "")), .Names = c("LENGTH", "pLENGTH", "LENGTH2", 
"BURN", "pBURN", "ts"), row.names = c(135L, 242L, 154L, 
56L, 265L, 151L, 328L, 160L, 90L, 364L), class = "data.frame")

#dput DF2 (sample)
DF2<- structure(list(TIMESTAMP = structure(c(1325883600, 1330030800, 
1337371200, 1339876800, 1339531200, 1350590400, 1325797200, 1341950400, 
1335556800, 1340827200), class = c("POSIXct", "POSIXt")), P = c(0, 
0, 0, 0, 1.3, 0, 0, 0, 0, 0), WS = c(4.023, 5.364, 4.917, 
3.129, 4.023, 4.023, 3.576, 4.023, 2.235, 2.682), WD = c(165, 
217.5, 34.5, 292.75, 167.75, 172.75, 319.25, 129.5, 148, 196)), .Names = c("ts", 
"P", "WS", "WD"), row.names = c(6L, 54L, 139L, 286L, 
164L, 292L, 5L, 192L, 118L, 121L), class = "data.frame")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:28:53+00:00Added an answer on June 18, 2026 at 2:28 am

    You can try this :

    > DF1$ts1 <- format(DF1$ts,'%Y-%m-%d')
    > DF2$ts1 <- format(DF2$ts,'%Y-%m-%d')
    > merge(DF1,DF2,by.x='ts1',by.y ='ts1')
             ts1 LENGTH pLENGTH LENGTH2 BURN pBURN                ts.x                ts.y P    WS     WD
    1 2012-06-16     30       0      30    1     1 2012-06-16 06:00:00 2012-06-16 22:00:00 0 3.129 292.75
    2 2012-06-27     50       1      50    1     1 2012-06-27 06:00:00 2012-06-27 22:00:00 0 2.682 196.00
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two android applications. The apks are Hello.apk and Fonts.apk I would like
I have two different strings: Baby 14% 28.07.2012 Hello 2% 15.06.16 Ten (baby or
Possible Duplicate: [F#] How to have two methods calling each other? Hello all, I
Hello I am brand new to xCode and iPhone development. I have two different
I have two arrays: $array1 = array(1=>1,10=>1,12=>0,13=>13); $array2 = array(1=>Hello,10=>Test,12=>check,13=>error); Here $array1 has keys
Hello I have a UISegmentedControl with two segments. The selected segment is modified programmatically
Hello I have problem to put together animations of two separate objects to second
Let's say I have these two arrays: string[] arr1 = new string[2]{Hello, Stack} string[]
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello I have two text inputs which get their values from a datepicker. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.