Dear Adams:
Thanks. It works very well.
Art Tsay
>
> You could try something like this. The hard part is getting the
> monthly RIT from COMPANY. I used matrix subscripting to do this.
>
> m <- cbind(match(CHOOSE$CMPY, COMPANY$CMPY),
> match(CHOOSE$MONTH, names(COMPANY)))
> mktsel <- match(CHOOSE$MONTH, MARKET$MONTH)
> SAMPLE <- data.frame(CMPY=CHOOSE$CMPY, MONTH=CHOOSE$MONTH,
> RIT=COMPANY[m], RMT=MARKET$RMT[mktsel], RFT=MARKET$RFT[mktsel])
>
> Hope this helps.
>
> JVA
> jean_adams@usgs.gov
>
>
> ______________________________ Reply Separator ______________________________
> ___
> Subject: [S] How to do these knids of merge
> Author: Art Tsay <wwchang@m2.is.net.tw> at NBS-Internet-Gateway
> Date: 4/27/99 10:59 AM
>
>
> Hi:
>
> Good Day!
>
> I'm a newbie of S-PLUS, using S-PLUS 4.0 for windows.
> I've got a problem which has spent me 2 days and I still don't
> know how to make it.
>
> What I want to do is to use data.frame CHOOSED to lookup data.frames
> COMPANY and MARKET and get the result data.frame SAMPLE.
>
> My problem is how to write this function. Is there any similar
> function that I can use?
>
> Thank you for your reading.
>
>
> data.frame: MARKET
>
> (row.names) MONTH RMT RFT
> -------------------------------------
> M8601 M8601 1,73 0.46
> M8602 M8602 1.04 0.46
> M8603 M8603 2.44 0.46
> ..
> M8912 M8912 0.63 0.50
>
> data.frame: COMPANY
>
> (row.names) CMPY M8601 M8602 ... M8910
> ------------------------------------------------------
> C2301 C2301 3.77 1.28 ... 0.23
> C2303 C2302 -2.18 -1.66 ... 0.51
> C2303 C2303 0.64 0.23 ... -1.87
> C2304 C2304 0.12 1.33 ... 3.21
> C2305 C2305 0.88 1.87 ... 1.58
> C2306 C2306 1.18 0.52 ... 2.38
> C2307 C2307 6.44 0.77 ... -0.68
> C2308 C2308 -1.23 0.22 ... -0.69
> C2309 C2309 -0.64 0.14 ... 1.44
> ..
> C9918 C9918 8.77 2.44 ... -3.87
>
> data.frame: CHOOSED
>
> CMPY MONTH
> ----------------------
> [1,] C2304 M8601
> [2,] C2308 M8601
> [3,] C2303 M8601
> ..
> [511,] C2303 M8603
> [512,] C9918 M8602
>
> data.frame: SAMPLE
>
> CMPY MONTH RIT RMT RFT
> ------------------------------------
> C2304 M8601 0.12 1.73 0.46
> C2308 M8601 -1.23 1.73 0.46
> C2303 M8601 0.64 1.73 0.46
> ..
> C9918 M8910 -3.87 0.03 0.50
>
> -----------------------------------------------------------------------
> This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
> send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
> message: unsubscribe s-news
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|