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

  • Home
  • SEARCH
  • 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 9218503
In Process

The Archive Base Latest Questions

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

I’ve been struggling to do something is probably horribly simple on R. What I

  • 0

I’ve been struggling to do something is probably horribly simple on R. What I am trying to do is to update a XTS object column using another XTS object.

Let’s say I have the following XTS object, named Object1:

A B
2000-01-03 , 14, NA
2000-01-04 , NA, NA
2000-01-05 , 16, 100
2000-01-06 , NA, 200

And the following XTS object, named Object2:

A
2000-01-05 , 160
2000-01-06 , 20

I am looking for a way to update Object1 with values from Object2, having the following result:

A B
2000-01-03 , 14, NA
2000-01-04 , NA, NA
2000-01-05 , 160, 100
2000-01-06 , 20, 200

If I do merge(Object1,Object2), I will have:

A B A.1
2000-01-03 , 14, NA, NA
2000-01-04 , NA, NA, NA
2000-01-05 , 16, 100, 160
2000-01-06 , NA, 200, 20

Which is absolutely not what I’m looking for, since I am trying to update Object1$A based on Object2$A.

What am I missing here?

Here is the output of dput(Object1) and dput(Object2) to make this reproducible:

> dput(Object1)
structure(c(14, NA, 16, NA, NA, NA, 100, 200), .Dim = c(4L, 2L
), index = structure(c(946857600, 946944000, 947030400, 947116800
), tzone = "UTC", tclass = "Date"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", .Dimnames = list(
    NULL, c("A", "B")), class = c("xts", "zoo"))

> dput(Object2)
structure(c(160, 20), .Dim = c(2L, 1L), index = structure(c(947030400, 
947116800), tzone = "UTC", tclass = "Date"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", .Dimnames = list(
    NULL, "A"), class = c("xts", "zoo"))
  • 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:52:48+00:00Added an answer on June 18, 2026 at 2:52 am

    You can subset Object1 using the index of Object2

    > Object1[index(Object2), "A"] <- Object2$A
    > Object1
                 A   B
    2000-01-03  14  NA
    2000-01-04  NA  NA
    2000-01-05 160 100
    2000-01-06  20 200
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm making a simple page using Google Maps API 3. My first. One marker
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am confused How to use looping for Json response Array in another Array.
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to understand how to use SyndicationItem to display feed which is

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.