[R-SIG-Finance] Coercing LHS to a list

rex rex at nosyntax.net
Thu Sep 27 09:06:25 CEST 2012


sean fallon <sf99167 at yahoo.com> [2012-09-26 23:27]:
>Now one more error to sort ....
>
>library(quantmod)
>getSymbols("INFY.BO", from="2008-01-01")
>data<-INFY.BO
>#Add the SMA/LMA
>h=data[,4]    <---- this is close, not high
>c=data[,5]    <---- this is volume, not close
>hcdif=h-c

I'd replace 3 the lines above with:
hcdif = Hi(data)-Cl(data)

>data$smv=filter(data[,5],rep(1/7,7), sides=1) 
>data$lmv=filter(data[,5],rep(1/21,21), sides=1)
>The data$smv has not error

Do you want:
datasmv=filter(Cl(data),rep(1/7,7), sides=1) 
datalmv=filter(Cl(data),rep(1/21,21), sides=1)

HTH,

-rex
-- 
Change is inevitable, except from a vending machine.



More information about the R-SIG-Finance mailing list