Skip to content
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

error using apply.yearly inside xts package #185

Closed
espher1987 opened this issue May 9, 2017 · 2 comments
Closed

error using apply.yearly inside xts package #185

espher1987 opened this issue May 9, 2017 · 2 comments

Comments

@espher1987
Copy link

I have been using ts objects for a while but not too much xts, so i was trying to calculate mean, sum, last, first... (FUN) for every year in economic time series. When i try it i have weird result.

This is a quick example: Considering x and y like monthly series, for two consecutive years:

x <- 1:12
y <- 1:12
serie <- c(x,y)

Then i create a ts object

serie <- ts(serie,1990,,12)
now i convert it to xts object

library(xts)

serie.xts <- as.xts(serie)

plot(serie.xts)

as far i see, the series is properly created

serie.xts
The series looks ok

ene 1990    1
feb 1990    2
mar 1990    3
abr 1990    4
may 1990    5
jun 1990    6
jul 1990    7
ago 1990    8
sep 1990    9
oct 1990   10
nov 1990   11
dic 1990   12
ene 1991    1
feb 1991    2
mar 1991    3
abr 1991    4
may 1991    5
jun 1991    6
jul 1991    7
ago 1991    8
sep 1991    9
oct 1991   10
nov 1991   11
dic 1991   12

Then comes my problem

for example, i try to get the last value for every year, as far i know this is what this function do:

apply.yearly(serie.xts,FUN = "last")
but i get this:

ene 1990    1
ene 1991    1
dic 1991   12

I was expecting this: dic 1990 12 dic 1991 12
i try this:

period.apply(INDEX = endpoints(x = serie.xts, on = "years"), x = serie.xts, FUN = "last")

but also give me the same result:

ene 1990    1
ene 1991    1
dic 1991   12

i'm using
R 3.3.3
xts 0.9-7
zoo 1.8-0

@joshuaulrich
Copy link
Owner

I cannot replicate the issue using the development version of xts. I assume it was fixed by #3, so I am closing as a duplicate.

@espher1987
Copy link
Author

You are right, i don't use the github to install packages so much, i didn't notice that.
Do you have any plan to update the cran version?
The last cran version was published 2014-01-02. so i suppose there is a lot of bugs that has been already fixed. Thanks for your amazing packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants