[R] Help with data type
ehxpieterse
eduard.pieterse at macquarie.com
Mon Aug 3 16:48:10 CEST 2009
Hi there,
Using a quantmod function, I calculate the daily change between two points
in a time series. However, I don't think I am using the data correctly.
Code:
getSymbols("^GSPC", src="yahoo")
CloseData <- Cl(GSPC)
Delta <- diff(CloseData, lag=1)
for (i in 3:length(Delta)) {
if (Delta[i]>Delta[i-1]) sum <- sum + Delta
}
I can't seem to use the Delta variable. Can anyone point me in the right
direction to transform the variable into a usable one?
Example:
> Delta[i-1]
GSPC.Close
2000-01-04 -55.8
> Delta[i]
GSPC.Close
2000-01-05 2.69
> Delta[i-1]*10
GSPC.Close
2000-01-04 -558
> Delta[i-1]+Delta[i]
Data:
numeric(0)
Index:
NULL
Thanks in advance,
Eduard
--
View this message in context: http://www.nabble.com/Help-with-data-type-tp24792149p24792149.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list