I am pretty new to R so I assume I have some beginner questions...
I have my data as an xts time series, but I would look to remove one (or more) dates from the data. Below is the tail of my data and the class.
What I would like to do is to remove the whole line for [2017-11-16] from the [x] series. Is there a simple way of doing it?
> tail(x)
CC1.CLOSE CC1.HIGH CC1.LOW CC1.OPEN
2017-11-09 2185 2198 2169 2196
2017-11-10 2212 2226 2179 2186
2017-11-13 2201 2214 2178 2199
2017-11-14 2155 2204 2152 2196
2017-11-15 2129 2162 2110 2155
2017-11-16 2140 2152 2132 2133
> class(x)
[1] "xts" "zoo"
> str(x)
An ‘xts’ object on 2016-01-04/2017-11-16 containing:
Data: int [1:474, 1:4] 3063 2998 2920 2902 2956 2841 2799 2831 2796 2844 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:4] "CC1.CLOSE" "CC1.HIGH" "CC1.LOW" "CC1.OPEN"
Indexed by objects of class: [POSIXct,POSIXt] TZ: UTC
xts Attributes:
NULL
If you just want to remove the last row you can create a new xts from X like so:
x.new <- first(x, (length(MSFT[,1]) - 1))
This will remove the last row.
you can also get rid of the index by doing: coredata(x)
which can sometimes make it easier to manipulate data.