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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:23:28+00:00 2026-05-27T23:23:28+00:00

I have 2 lists whose components are xts objects (co and oc). I want

  • 0

I have 2 lists whose components are xts objects (co and oc). I want to produce another list object that has the result of oc / co.

> length(co)
[1] 1064
> length(oc)
[1] 1064

> tail(co[[1]])
                [,1]
2011-12-22 0.3018297
2011-12-23 0.2987450
2011-12-27 0.2699710
2011-12-28 0.2706428
2011-12-29 0.2098897
2011-12-30 0.2089051


> tail(oc[[1]])
                [,1]
2011-12-22 0.6426411
2011-12-23 0.6462834
2011-12-27 0.6466680
2011-12-28 0.6741420
2011-12-29 0.6781371
2011-12-30 0.6650130


> co / oc
Error in co/oc : non-numeric argument to binary operator

If I specify an index of the lists the operation succeeds as follows:

> tail(co[[1]] / oc[[1]])
                [,1]
2011-12-22 0.4696707
2011-12-23 0.4622507
2011-12-27 0.4174800
2011-12-28 0.4014627
2011-12-29 0.3095093
2011-12-30 0.3141369

I want to do this without writing a loop to iterate through each component of the two lists (1064 components in total).

Any help would be greatly appreciated. Thank you.

  • 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-27T23:23:29+00:00Added an answer on May 27, 2026 at 11:23 pm

    Something like this may work:

    mapply("/",co,oc,SIMPLIFY = FALSE)
    

    although there are probably countless ways of doing this that are all mostly equivalent.

    Here’s a minimal example using some sample data from the xts package:

    data(sample_matrix)
    sample.xts <- as.xts(sample_matrix, descr='my new xts object')
    v1 <- list(a = sample.xts[,1],b = sample.xts[,2])
    v2 <- list(a = sample.xts[,3],b = sample.xts[,4])
    mapply("/",v1,v2,SIMPLIFY = FALSE)
    

    Update:
    We can now use Map which is basically the mapply(..., simplify = FALSE) by default.

    Map("/",co,oc)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two lists of custom objects and want to update a field for
I have two lists of objects. Each list is already sorted by a property
I have two lists and I want to select items that are not in
HI I have 2 lists, list 1 contains objects and list 2 contains strings,
I get object from hibernate query. Then i have list of fields, whose getters
I have the following scenario: My page has a dropdown list that allows user
I have an application that's dealing with a required list of files it has
I have a DGV bound to a list of objects whose properties include a
I have a WinForms .NET datagrid whose data source is a List<cLineItem> called lines.
I have a DataGridViewComboBoxCell, whose DataSource is a List. When an item is selected

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.