[R-SIG-Finance] Manipulate database

Brian G. Peterson brian at braverock.com
Wed Oct 28 19:46:32 CET 2009


While all this can be accomplished in R, this question would be best 
asked on R-help, as it has nothing to do with finance specifically.  If 
you want an answer here or on r-help, I would suggest providing a 
reproducible example and the code you've tried.

That said, if you have a "database", then write your database query to 
give you the data in the format you need it in.  A couple of "join" and 
"coalesce" statements in a "where" look like they would do the trick.

Regards,

    - Brian

Clhis Alberty wrote:
> Guys
> I have a problem.
> I have a  Big database (in the table below) that i need to manupulate the data across. But I´m not getting.
> I tried to use function aggragate,table and tapply, to a cross date whit the clossing price equit. But i din´t succeed.
>  exemplo
> My database
>
> Simbulo Período      Data   hora Abertura Máximo Mínimo Fechamento Quantidade Financeiro
> 1  ABCB11       D 24/9/2007 185000    93.89   93.9   93.7       93.8      16300    1529782
> 2  PETR4       D 21/9/2007 185000       92  94.06     92      92.95      91800    8448657
> 3  PETR3       D 20/9/2007 185000     93.4   93.5   92.5       92.5      11100    1031339
> 4  VALE5        D 19/9/2007 185000       94     94   93.5      93.99       3300     309885
> 5  VALE3       D 18/9/2007 185000    92.99     94   91.5         94      10500     976880
> 6  BBAS3       D 17/9/2007 185000       93     93     92       92.7      49700    4604635
>  
> I will need to do (date / Closing Equite)
>
>          Date ABCB11 PETR4 PETR3 VALE5 VALE3 BBAS3 
> 24/9/2007    93.7 93.7 93.7 93.7 93.7 93.7 
> 21/9/2007    92 92 92 92 92 92 
> 20/9/2007      92.5 92.5 92.5 92.5 92.5 92.5 
> 19/9/2007    93.5 93.5 93.5 93.5 93.5 93.5 
> 18/9/2007    91.5 91.5 91.5 91.5 91.5 91.5 
> 17/9/2007    92 92 92 92 92 92 
>
> what is the function to accomplishment this intersection?
> someone help me?
> Thank.
> Clhis Alberty
>
>
>       ____________________________________________________________________________________
> [[elided Yahoo spam]]
>
> 	[[alternative HTML version deleted]]
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.



More information about the R-SIG-Finance mailing list