[R] Fill dataframe from a table according to a criteria
John Kane
jrkrideau at yahoo.ca
Fri Jul 31 19:00:21 CEST 2009
Your posting arrives as plain text so it is impossible to see what you had highlighed in red. Also it is very difficult to see what is in that data.frame. Could you either reduce the data.frame to make minimal, self-contained, reproducible code. A good approach might be to use dput to create a handy form of the data.frame that a reader can easily use. See ?dput
--- On Fri, 7/31/09, Meenu Sahi <meenusahi at gmail.com> wrote:
> From: Meenu Sahi <meenusahi at gmail.com>
> Subject: [R] Fill dataframe from a table according to a criteria
> To: "R" <r-help at r-project.org>
> Received: Friday, July 31, 2009, 12:13 PM
> 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
>
> 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 called mydata which is given below
> where I want to
> fill in the last four columns of probabilities taken from
> States.Prob
> according to the change and state in mydata4:-
> PxMid EU0006MIndex.x DMSW1Curncy.x DMSW2Curncy.x
> DMSW3Curncy.x
> 1 01/01/2003 2.80113
> 2.7070
> 2.8920 3.1720
> 2 01/01/2007 3.85350
> 4.0760
> 4.1250 4.1230
> 3 01/02/2002 3.41563
> 3.6385
> 4.0810 4.3587
> 4 01/02/2006 2.70000
> 2.9545
> 3.1672 3.2792
> 5 01/05/2002 3.49863
> 3.7940
> 4.2300 4.4920
> 6 01/05/2006 3.03588
> 3.3254
> 3.5950 3.7380
> DMSW4Curncy.x DMSW5Curncy.x DMSW6Curncy.x
> DMSW7Curncy.x DMSW8Curncy.x
> 1 3.4360
> 3.6640 3.8640
> 4.0360 4.1790
> 2 4.1230
> 4.1250 4.1350
> 4.1460 4.1620
> 3 4.5487
> 4.6988 4.8313
> 4.9338 5.0138
> 4 3.3627
> 3.4342 3.4899
> 3.5437 3.5941
> 5 4.7650
> 4.8675 5.0550
> 5.1600 5.2400
> 6 3.8290
> 3.9050 3.9690
> 4.0240 4.0750
> 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
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
__________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr!
More information about the R-help
mailing list