-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposed Time Shift/Lag Function #242
Comments
One thing I've considered is allowing the require(xts)
data(sample_matrix)
x <- as.xts(sample_matrix, dateFormat = "Date")
last(x, "week") # may also be preceded by a number (e.g. "2 weeks")
# Open High Low Close
# 2007-06-25 47.20471 47.42772 47.13405 47.42772
# 2007-06-26 47.44300 47.61611 47.44300 47.61611
# 2007-06-27 47.62323 47.71673 47.60015 47.62769
# 2007-06-28 47.67604 47.70460 47.57241 47.60716
# 2007-06-29 47.63629 47.77563 47.61733 47.66471
# 2007-06-30 47.67468 47.94127 47.67468 47.76719 So if Thoughts? |
Here is a quick example that demonstrates the functionality. The function allows one to answer the question, "For each observation, what is the value k seconds in the future?"
|
I don't like the inconsistency with
I think it would be better to name the function
|
I agree that we should probably roll this into |
- Added timelag function to lag by units of time rather than the discrete index values. - The arguments and functionality are consistent with lag.xts, only difference is to lag by units of time. This function should probably get integrated into lag.xts per comments from josh in issue #242. see issue #242
I propose adding functionality to shift or lag the index of an xts object by a specified number of seconds. This is similar to
lag.xts
, but the key difference is shifting by units of time (e.g. seconds) rather than an index. This is particularly useful for irregular time series such as high frequency market data.Here is a prototype function that provides the proposed functionality.
The text was updated successfully, but these errors were encountered: