R-experts, I have a bunch of files (by date) that I can read into
dataframes as below.
df$today:
identifier rtgmdy rtgmdy_dt rtgmdy_watch rtgmdy_nowatch
rtgmdy_watch_dt rtgsp rtgsp_dt
310000031 Aa3 20050701 Aa3 NA AA-
20050510
310000086 B1 20070920 B1 NA B+
20070828
310000106 Baa2 20040326 Baa2 NA BBB
20051003
310000170 Baa3 20070601 Baa3 NA BBB+
20051024
310000225 Ba2 20070601 Ba2 NA BB+
20070423
310000386 Baa3 20070320 Baa3 NA BBB-
20040331
df$20050701:
identifier rtgmdy rtgmdy_dt rtgmdy_watch rtgmdy_nowatch
rtgmdy_watch_dt rtgsp rtgsp_dt
310000031 Aa2 20030501 Aa3 NA AA-
20050510
I want to re-cast the combination of df$today and df$20050701 as
follows:
PART A: Ideal result: Where I can have just identifiers and dates and
see what changed for that date(s), and also what it changed from. I
realize that it takes a combo of some nifty melt and cast work that my
iterations have thus far not resulted.
identifier Chg Date Var1 Var2 Var3=(Previous Var2)
310000031 20050701 rtgmdy Aa3 Aa2
310000031 20050510 rtgsp AA-
310000086 20070920 rtgmdy B1
310000086 20070828 rtgsp B+
PART B: Less than ideal result (where we don't the lookup to get the
previous value). I'll live with this type of result also. I realize the
lookups can be expensive computationally.
identifier Chg Date Var1 Var2
310000031 20050701 rtgmdy Aa3
310000031 20050510 rtgsp AA-
310000086 20070920 rtgmdy B1
310000086 20070828 rtgsp B+
Any pointers? Thanks!
--------------------------------------------------------
This message w/attachments (message) may be privileged, confidential or
proprietary, and if you are not an intended recipient, please notify the sender,
do not use or share it and delete it. Unless specifically indicated, this
message is not an offer to sell or a solicitation of any investment products or
other financial product or service, an official confirmation of any transaction,
or an official statement of Merrill Lynch. Subject to applicable law, Merrill
Lynch may monitor, review and retain e-communications (EC) traveling through its
networks/systems. The laws of the country of each sender/recipient may impact
the handling of EC, and EC may be archived, supervised and produced in countries
other than the country in which you are located. This message cannot be
guaranteed to be secure or error-free. This message is subject to terms
available at the following link: http://www.ml.com/e-communications_terms/. By
messaging with Merrill Lynch you consent to the foregoing.
--------------------------------------------------------
[[alternative HTML version deleted]]