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 6186833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:57:23+00:00 2026-05-24T01:57:23+00:00

If one of my tables has multiple values for the time stamp, and the

  • 0

If one of my tables has multiple values for the time stamp, and the other just one, can I repeat the value of the single item in the multiple values?

For instance:

XTS_A:

2011/01/01 10:00:00,Bar
2011/01/01 10:00:01,Baz

XTS_B:

2011/01/01 10:00:00,A
2011/01/01 10:00:00,B
2011/01/01 10:00:00,C
2011/01/01 10:00:01,B

Merge_Result:

2011/01/01 10:00:00,A,Bar
2011/01/01 10:00:00,B,Bar
2011/01/01 10:00:00,C,Bar
2011/01/01 10:00:01,B,Baz

Reproducible example:

library(zoo)
library(xts)
XTS_A <- structure(c("Bar", "Baz"), .Dim = c(2L, 1L), index = structure(c(1293894000, 1293894001), tzone = "", tclass = c("POSIXt", "POSIXct")), class = c("xts",  "zoo"), .indexCLASS = c("POSIXt", "POSIXct"), .indexTZ = "")
XTS_B <- structure(c("A", "B", "C", "B"), .Dim = c(4L, 1L), index = structure(c(1293894000,  1293894000, 1293894000, 1293894001), tzone = "", tclass = c("POSIXt",  "POSIXct")), class = c("xts", "zoo"), .indexCLASS = c("POSIXt",  "POSIXct"), .indexTZ = "")
  • 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-05-24T01:57:23+00:00Added an answer on May 24, 2026 at 1:57 am

    What about just filling down afterwards? Somewhat ugly example (uses a loop, but hard to avoid with sequential dependencies like this):

    mrg <- merge(XTS_A,XTS_B)
    for(r in seq(nrow(mrg)) ) {
      if(is.na(mrg[r,1])) {
        mrg[r,1] <- mrg[r-1,1] 
      }
    }
    
    > mrg
                        XTS_A XTS_B
    2011-01-01 16:00:00 "Bar" "A"  
    2011-01-01 16:00:00 "Bar" "B"  
    2011-01-01 16:00:00 "Bar" "C"  
    2011-01-01 16:00:01 "Baz" "B"
    

    Joran’s suggestion saves typing using the zoo package’s fill-down function:

    mrg[,1] <- na.locf(as.vector(mrg$XTS_A))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataset with multiple tables. One table in particular has one record
My database has 7 tables: one is the parent (feeds) and the other 3
I have SQL Server 2008 R2 and one of my tables has a date
I have an existing database in mysql. One of my tables has discontinuous ids.
Is there a general term for a pairing of tables where one has header
One of my tables in my SQL database has a growth rate of two
One of the tables in my database has three columns. They are dt_id (PK),
I have a DB with many tables and one of the table has fields:
I have a database with many tables and one particular table has columns: name
Suppose I have two tables that are linked (one has a foreign key to

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.