s-news
[Top] [All Lists]

Re: [S] How to do these knids of merge

To: "sinclair, andrew (MIP London)" <asinclair@edfman.co.uk>
Subject: Re: [S] How to do these knids of merge
From: Art Tsay <wwchang@m2.is.net.tw>
Date: Wed, 28 Apr 1999 00:41:27 +0800
Cc: Splus News <s-news@wubios.wustl.edu>
In-reply-to: <B0000089753@mimesweeper.edfman.co.uk>
References: <B0000089753@mimesweeper.edfman.co.uk>
Sender: owner-s-news@wubios.wustl.edu
Thank you.  I'll try to learn how to use function tapply.

Regards, 
Art Tsay 

> 
> I think you'll need to write your own.
> 
> Its not too difficult I think, something like:
> 
> > marketbit <- MARKET [ CHOOSED$MONTH, c('RMT' , 'RFT') ]
> > select.companybit <- function(i){
>      icmpy <- CHOOSED[i , 'CMPY']
>      imonth <- CHOOSED[i , 'MONTH']
>      COMPANY[icmpy , imonth]
>      }
> > companybit <- tapply(1:nrow(CHOOSED), 1:nrow(CHOOSED), select.companybit)
> > SAMPLE <- data.frame(CHOOSED, marketbit, RFT = companybit)
> 
> I haven't bothered to set up all your data frames and try this
> out, so I hope it works ...  Shouldn't require much fixing if it doesn't.
> 
> Good luck,
> 
> Andrew
> 
>  ----------
> From: Art Tsay
> To: Splus News
> Subject: [S] How to do these knids of merge
> Date: 27 April 1999 10:59
> 
> 
> 
> 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

<Prev in Thread] Current Thread [Next in Thread>