I am using the data of the rugarch package:
library(rugarch)
data(sp500ret)
The data look like:
head(sp500ret)
SP500RET
1987-03-10 0.008840447
1987-03-11 -0.001892734
1987-03-12 0.003129678
1987-03-13 -0.004577455
1987-03-16 -0.005742768
1987-03-17 0.014603325
I just want to have the first e.g. 1000 values, so I tried
sp500retmod<-sp500ret[-c(1001:length(sp500ret[,1])),1]
But this gives
head(sp500retmod)
[1] 0.008840447 -0.001892734 0.003129678 -0.004577455 -0.005742768
[6] 0.014603325
So the rownames are deleted, how can I get the first 1000 values and keep the rowname, the date?
I also tried
sp500retmod<-sp500ret[-c(1001:length(sp500ret[,1])),]
but this does also not work.