Dear sir, I am extremely sorry for messing up the logic asking for help w.r.t. my earlier mails
I have tried to explain below what I am looking for. I have a database (say, currency_rates) storing datewise currency exchange rates with some base currency XYZ. currency_rates <- data.frame(date = c("12/31/2010", "12/30/2010", "12/29/2010", "12/28/2010", "12/27/2010","12/24/2010", "12/23/2010", "12/22/2010", "12/21/2010", "12/20/2010"), USD = c(112.05, 112.9, 110.85, 109.63, 108.08, 111.23, 112.49, 108.87, 109.33, 111.88), GBP = c(171.52, 168.27,169.03, 169.64, 169.29, 169.47, 170.9, 168.69, 170.9, 169.96), EURO = c(42.71, 42.68, 41.86, 44.71, 44.14, 44.58, 41.07, 42.23, 44.55, 41.12), CHF = c(41.5, 41.47, 42.84, 43.44, 43.69, 42.3, 42.05, 41.23, 42.76, 43.79), AUD = c(109.55, 102.52, 114.91, 122.48, 122.12, 123.96, 100.36, 110.19, 121.58, 103.46)) I have a portfolio consisting of some of these currencies. At this moment, suppose my portfolio has following currency transactions. i.e following is my current portfolio and has 2 USD transactions, 2 EURO transactions and a CHF transactions. portfolio_currency_names = c("USD", "USD", "EURO", "CHF", "EURO", "USD") # ____________________________________ My objective is AS PER THE PORTFOLIO, I need to generate a data.frame giving respective currency returns. Thus, I need to have an output like USD USD EURO CHF EURO USD -0.0076 -0.0076 0.0007 0.0007 0.0007 -0.0076 0.0183 0.0183 0.0194 -0.0325 0.0194 0.0183 0.0111 0.0111 -0.0659 -0.0139 -0.0659 0.0111 0.0142 0.0142 0.0128 -0.0057 0.0128 0.0142 -0.0287 -0.0287 -0.0099 0.0323 -0.0099 -0.0287 -0.0113 -0.0113 0.0820 0.0059 0.0820 -0.0113 0.0327 0.0327 -0.0279 0.0197 -0.0279 0.0327 -0.0042 -0.0042 -0.0535 -0.0364 -0.0535 -0.0042 -0.0231 -0.0231 0.0801 -0.0238 0.0801 -0.0231 Thus, my requirement is to have the dataframe as per the composition of my portfolio. Thus, if there are only 2 transactions i.e. if my portfolio contains say only CHF and AUD, I need the return calculations done only forCHF and AUD. CHF AUD 0.0007 0.0663 -0.0325 -0.1141 -0.0139 -0.0638 -0.0057 0.0029 0.0323 -0.0150 0.0059 0.2112 0.0197 -0.0934 -0.0364 -0.0984 -0.0238 0.1614 I once again apologize for not asking my requirement properly thereby causing not only inconvenience to all of you, but also wasting your valuable time. Its not that I wasn't careful while asking for guidance for my requirement, I wasn't clear about it. I am sorry for the same once again. I request you to please help me. Amelia Vettori [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.