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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:39:56+00:00 2026-06-16T11:39:56+00:00

I have a list object as below: structure(list(bga_u = structure(list(buy_target_price = numeric(0), sell_target_price =

  • 0

I have a list object as below:

structure(list(bga_u = structure(list(buy_target_price = numeric(0), 
    sell_target_price = numeric(0), units_holding = 0, tx_record = structure(list(
        `2010-12-01` = structure(list(buy_date = structure(14944, class = "Date"), 
            offer_price = 40.58, buy_unit = 3.15931809278285, 
            status = "hold"), .Names = c("buy_date", "offer_price", 
        "buy_unit", "status")), `2011-01-03` = structure(list(
            buy_date = structure(14977, class = "Date"), offer_price = 42.2, 
            buy_unit = 3.03803621339166, status = "hold"), .Names = c("buy_date", 
        "offer_price", "buy_unit", "status")), `2011-02-01` = structure(list(
            buy_date = structure(15006, class = "Date"), offer_price = 42.59, 
            buy_unit = 3.01021667539629, status = "hold"), .Names = c("buy_date", 
        "offer_price", "buy_unit", "status")), `2011-03-01` = structure(list(
            buy_date = structure(15034, class = "Date"), offer_price = 43.37, 
            buy_unit = 2.95607858439309, status = "hold"), .Names = c("buy_date", 
        "offer_price", "buy_unit", "status")), `2011-04-01` = structure(list(
            buy_date = structure(15065, class = "Date"), offer_price = 43.35, 
            buy_unit = 2.95744240380919, status = "hold"), .Names = c("buy_date", 
        "offer_price", "buy_unit", "status")), `2011-05-03` = structure(list(
            buy_date = structure(15097, class = "Date"), offer_price = 44.53, 
            buy_unit = 2.87907316876551, status = "hold"), .Names = c("buy_date", 
        "offer_price", "buy_unit", "status"))), .Names = c("2010-12-01", 
    "2011-01-03", "2011-02-01", "2011-03-01", "2011-04-01", "2011-05-03"
    ))), .Names = c("buy_target_price", "sell_target_price", 
"units_holding", "tx_record")), bwg_u = structure(list(buy_target_price = numeric(0), 
    sell_target_price = numeric(0), units_holding = 0, tx_record = structure(list(
        `2010-11-02` = structure(list(buy_date = structure(14915, class = "Date"), 
            offer_price = 63.15, buy_unit = 2.03016830095215, 
            status = "hold"), .Names = c("buy_date", "offer_price", 
        "buy_unit", "status")), `2010-12-01` = structure(list(
            buy_date = structure(14944, class = "Date"), offer_price = 64.19, 
            buy_unit = 1.99727571592348, status = "hold"), .Names = c("buy_date", 
        "offer_price", "buy_unit", "status")), `2011-09-01` = structure(list(
            buy_date = structure(15218, class = "Date"), offer_price = 69.29, 
            buy_unit = 1.85026884406304, status = "hold"), .Names = c("buy_date", 
        "offer_price", "buy_unit", "status")), `2011-10-03` = structure(list(
            buy_date = structure(15250, class = "Date"), offer_price = 58.05, 
            buy_unit = 2.20852934031229, status = "hold"), .Names = c("buy_date", 
        "offer_price", "buy_unit", "status"))), .Names = c("2010-11-02", 
    "2010-12-01", "2011-09-01", "2011-10-03"))), .Names = c("buy_target_price", 
"sell_target_price", "units_holding", "tx_record"))), .Names = c("bga_u", 
"bwg_u"))

This is a “list in a list” object composed of 3 levels:

  • level 1: names of all fund (2 funds here: bga_u and bwg_u)
  • level 2: target buy price; target sell price; and units holding
  • level 3: details of a particular trade (e.g. unit bought)

The “unit holding” stored in level 2 is calculated by summing the “buy unit” in level 3 for each trade, if the status in for that particular trade is still “hold”.

How can I calculate the “unit holding” for each fund and put in level 2?

(I used R for 2-3 years but I am new to the list object, I may be conceptually wrong about list.)

  • 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-16T11:39:57+00:00Added an answer on June 16, 2026 at 11:39 am

    Assuming that whole list is named as dl, apply function to every first level (fund) of list. First, make data frames of trade records, then sum units and put them in units_holding.

    for(i in 1:length(dl)){
      df<-do.call(rbind,lapply(dl[[i]]$tx_record,data.frame))
      dl[[i]]$units_holding<-sum(df$buy_unit[df$status=="hold"])
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Generic List object which hold below table as its own value.
I have a class structure like below. ObservableCollection<Group> deviceCollection = new ObservableCollection<Group>(); public class
I have an object structure that looks like this: var Results = new List<ResultObj>()
I have an interesting problem Here is the object structure public class Testdata {
I have a master product list that has a logical object structure: var myProducts
Let's say I have a simple parent->child class structure as shown below Public Class
I have a object list as below: ID Name PageOrder 1 Home 1 2
I have a list of objects (Debtors) in this structure public class DebtorDto {
I have a List object and I want to remove the duplicated items but
I have a list object List<Documents> , and inside that I have another list

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.