-
-
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
Why sum and mean works different in apply.monthly? #124
Comments
Why not use colMeans and colSums to make sure you get what you think you're getting? x<-xts(matrix(rnorm(1000),ncol=10),order.by=as.Date(1:100))
mean(x)
sum(x)
apply.weekly(x,sum)
apply.weekly(x,mean)
apply.weekly(x,colSums)
apply.weekly(x,colMeans) |
Thanks, just discovered I can do it with |
The problem is that xts defines
Or maybe they should just be removed all together? They're not exported, so CRAN likely would not allow their use in other packages. |
In my opinion is better just remove them and let |
Using colSums takes care of the sum function not being applied by columns, however what would be a similar fix for the sd( ) function, which, like sum( ), is not applied by columns in period.apply. |
A late answer, but the package matrixStats has all these functions available for columns and rows. Using the example above that would be:
|
I just pushed a commit with the best solution I could think of. The current behavior is maintained, but prints a message every time The message says to use |
When
apply.monthly
in axts
multivaluate time series (with more than one column)apply.monthly(xts.ts, sum)
returns a one column time series butapply.monthly(xts.ts, mean)
returns the same number of columns of the original.Here is an example:
The same is true with other
xts
apply
functions.This seems inconsistent.
The text was updated successfully, but these errors were encountered: