4
I’m working with this date.frame:
St <- data.frame(read.csv2("interest_LastMonthDay.csv"))
Date AAA_S.t. Date.1 BBB_S.t. Date.2 CCC_S.t.
1 27/12/88 1,80400 28/12/88 0,8368 28/12/88 0,0080
2 28/12/88 1,78900 29/12/88 0,8386 29/12/88 0,0079
3 29/12/88 1,78950 30/12/88 0,8384 30/12/88 0,0080
4 30/12/88 1,80850 2/01/89 ND 2/01/89 ND
5 2/01/89 ND 3/01/89 0,8398 3/01/89 0,0081
6 3/01/89 1,82250 4/01/89 0,8389 4/01/89 0,0080
7 4/01/89 1,80700 5/01/89 0,8407 5/01/89 0,0080
8 5/01/89 1,79700 6/01/89 0,8367 6/01/89 0,0079
9 6/01/89 1,78000 9/01/89 0,8354 9/01/89 0,0079
10 9/01/89 1,76360 10/01/89 0,8327 10/01/89 0,0079
11 10/01/89 1,76370 11/01/89 0,8328 11/01/89 0,0079
12 11/01/89 1,78100 12/01/89 0,8356 12/01/89 0,0079
13 12/01/89 1,78400 13/01/89 0,8342 13/01/89 0,0079
I want to leave only the last values of each month. For this I used the endpoint function:
St_GBP<-St[,c(1:2)];St_GBP<-St_GBP[endpoints(St_GBP$Date, on = "months"), ]
It returns me the following error:
Error in try.xts(x, error = "must be either xts-coercible or timeBased") :
must be either xts-coercible or timeBased
How can I get around that?
I think the problem is in the columns of the dates that are factors
. But I couldn’t fix it:
class(St$Date);class(St$Date.1);class(St$Date.2)
[1] "factor"
[1] "factor"
[1] "factor"
Thank you.