Deare R users

I am new to R.
What I want to do is explained below;-
I have table called States.Prob which is given below:-
This table gives the probabilities of the changes in the swap curve
depending on the state of the swap curve. I want to put these probabilities
in my dataframe mydata(given after the prob table).
                 Prob of States
Changes  State1  State2 State3 State4
a             Pa1      Pa2     Pa3     Pa4
b             Pb1      Pb2     Pb3     Pb4
c             Pc1      Pc2     Pc3     Pc4
d             Pd1      Pd2     Pd3     Pd4

and I have a dataframe(with 93 rows) called mydata part of which(6 rows) is
given below where I want to fill in the last four columns with probabilities
taken from States.Prob according to the change and state in mydata4:-
Change  State  PState1  PState2  PState3  PState4
1 b       State1  Pb1
2 a       State4                                           Pa4
3 b       State2                Pb2
4 c       State3                             Pc3
5 d       State1  Pd1
6 a       State3                             Pa3

What I want to do is highlighted in Red.
How can I do this easily?

Many thanks for your time.

kind regards
Meenu
P.S. Thanks for your reply John. I've tried to put only the relevant columns
of the dataframe. Hope its more clear now.

        [[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.

Reply via email to