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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:38:17+00:00 2026-06-13T04:38:17+00:00

I have my list MF wich contains 105 lists. Every list, MF[[1]] MF[[2]] ….

  • 0

I have my list MF wich contains 105 lists. Every list, MF[[1]] MF[[2]] …. MF[[105]] contains different number of data frames. Thus, MF[[1]][[1]] exists but MF[[1]][[2]] is NULL because there is just one data frame for MF[[1]]. In the other hand MF[[2]] contains 15 different data frames, so MF[[2]][[1]] to MF[[2]][[15]] exists.

The colnames of all the data frames in every 105 list is:

[1] "Run"             "Fecha"           "Serie"           "Patrimonio"      "Ret Log Pat"     "Percentil 5%"    "Percentil Monto"

I’m gonna ask my question with a concrete example. Let’s use MF[[2]] wich contains 15 different data frames. Here are some headers of those data frames:

head(MF[[2]][[1]]):
 Run      Fecha Serie Patrimonio  Ret Log Pat Percentil 5% Percentil Monto
31 8011 2002-08-18     1 4191689227 -0.456258862   -0.1973659      1305605031
32 8011 2002-08-19     1 4749171865  0.124866449   -0.2179453       913558775
33 8011 2002-08-20     1 5132656241  0.077653052   -0.2179453      1035059470
34 8011 2002-08-21     1 5088469783 -0.008646158   -0.2179453      1118638070
35 8011 2002-08-22     1 4998945148 -0.017750234   -0.2179453      1109007841
36 8011 2002-08-23     1 5449454077  0.086288515   -0.2179453      1089496372

head(MF[[2]][[2]])
    Run      Fecha Serie Patrimonio   Ret Log Pat Percentil 5% Percentil Monto
31 8011 2006-05-09   100 6413583009 -0.0076314490  -0.07046562       455399234
32 8011 2006-05-10   100 6412446421 -0.0001772315  -0.07046562       451937105
33 8011 2006-05-11   100 6380254435 -0.0050328784  -0.07046562       451857014
34 8011 2006-05-12   100 6381112038  0.0001344061  -0.07046562       449588586
35 8011 2006-05-13   100 6381970402  0.0001345073  -0.07046562       449649018
36 8011 2006-05-14   100 6315827940 -0.0104180360  -0.07046562       449709503

head(MF[[2]][[3]])
    Run      Fecha Serie Patrimonio   Ret Log Pat Percentil 5% Percentil Monto
31 8011 2002-08-18     2 3147993667 -0.0395416467  -0.03216529       105340167
32 8011 2002-08-19     2 3065335420 -0.0266083198  -0.03778848       118957901
33 8011 2002-08-20     2 3044946268 -0.0066737439  -0.03778848       115834372
34 8011 2002-08-21     2 3089802537  0.0146239300  -0.03778848       115063897
35 8011 2002-08-22     2 3090714960  0.0002952578  -0.03778848       116758947
36 8011 2002-08-23     2 3230667973  0.0442864759  -0.03778848       116793426

What I want is an iteration or whatever, that matches the column "Fecha" ( which means "Date" by the way), and if the Date matches, calculates the percent which represent each row of the column "Patrimonio" over the total sum of "Patrimonio" in which date matches.

Example given:

In this case we got:

head(MF[[2]][[1]]):
     Run      Fecha Serie Patrimonio  Ret Log Pat Percentil 5% Percentil Monto
    31 8011 2002-08-18     1 4191689227 -0.456258862   -0.1973659      1305605031

 head(MF[[2]][[3]])
        Run      Fecha Serie Patrimonio   Ret Log Pat Percentil 5% Percentil Monto
    31 8011 2002-08-18     2 3147993667 -0.0395416467  -0.03216529       105340167

So, MF[[2]][[1]][1,2]==MF[[2]][[3]][1,2] ( Dates matches ), then I want a new column over each data frame like this:

  New column for MF[[2]][[1]] = MF[[2]][[1]][1,4]/(MF[[2]][[1]][1,4]+MF[[2]][[3]][1,4]) =  4191689227/( 4191689227+ 3147993667) ( Percent Calculation over "Patrimonio" column )

 New column for MF[[2]][[3]] = MF[[2]][[3]][1,4]/(MF[[2]][[1]][1,4]+MF[[2]][[3]][1,4]) =  3147993667/( 4191689227+ 3147993667) ( Percent Calculation over "Patrimonio" column )

The thing is that I must match all the 15 data frames to calculate the "Patrimonio" percent by the variable "Fecha" and so on for all the 105 lists. Hope my doubt is clear enough.

  • 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-13T04:38:18+00:00Added an answer on June 13, 2026 at 4:38 am

    I can’t easily use your data due to the “5%” in the headers. However, you need to use the apply family for the first step.

    lapply(MF, yourfunction)
    

    will apply yourfunction to each element of ML. Since each element of ML is a list also, you could lapply again (either in yourfunction or lapply(MF, lapply, yourfunction).

    yourfunction will be something that works to do the calculation you want on a single data.frame. I find it easiest to extract one from these nested structures and write a function that works for it. Then worry about applying it to all the members of nested lists.

    It sortof sounds like you’re wanting to compare the dates between data.frames. IF this is the case, your best bet is to combine them into a single frame rather than nested in a list.

    You can do this in a few ways, but I like plyr.

    library(plyr)
    ldply(unlist(MF, recursive=FALSE), as.data.frame)
    

    Then the comparisons are much more straight forward.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a checkboxlist wich contains a list of services loaded from a database
In my SharePoint site I have a list wich has a column that contains
I have list of structure. I want to modify a particular data from the
I have list of files which contain particular patterns, but those files have been
wich contains a list of students on the left and a lot of skills
Supposing I have a model Post , wich contains only the field desc .
I have one main xml file wich contains 2 components. Component 1 is an
I have a small code wich can return the list of files under any
I have a Shape class wich contains public Pen outlinePen; What I try to
I have a small custom dialog in wich I have a ListView with id: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.