Matthieu Stigler
2008-Jan-31 13:24 UTC
[Rd] Feature request: about lag(), which.min() and cat().
Hello I'm only user of R and have many little knowledge in programming but I permit to send you some whishes/suggestions for R. which.min like which(), which.min() should also include an argument arr.ind. Note that one can have it with which(a==min(a), arr.ind=TRUE) but if there is a reason to build a special function which.min, why not add also this nice argument? lag() If one wants to construct a time series model, it is often useful to have the lags matrix. This is available with embed(ts,k) but the time series class disappears. So it would be nice that the argument k of lag() also admit values of length >1, which would give the same result as embed() but keep the class. In his wish list of 1 January 2008 (point 8), Gabor Grothendieck spoke about a function Lag. Maybe also a function lags otherwise if the idea of length(k)>1 is not good? cat() It would be really nice if cat() could also include matrix and lists as values. This would allow big improvements for output written in a file. Thank you for what you make for R, it is a really nice program!
Gabor Grothendieck
2008-Jan-31 21:12 UTC
[Rd] Feature request: about lag(), which.min() and cat().
On Jan 31, 2008 8:24 AM, Matthieu Stigler <stigler3 at etu.unige.ch> wrote:> lag() > If one wants to construct a time series model, it is often useful to > have the lags matrix. This is available with embed(ts,k) but the time > series class disappears. So it would be nice that the argument k of > lag() also admit values of length >1, which would give the same result > as embed() but keep the class. In his wish list of 1 January 2008 (point > 8), Gabor Grothendieck spoke about a function Lag. Maybe also a function > lags otherwise if the idea of length(k)>1 is not good?It would be nice. Note that lag.zoo in the zoo package does supports this for zoo objects.> library(zoo) > z <- zoo((11:20)^2) > lag(z, 1:2)lag1 lag2 1 144 169 2 169 196 3 196 225 4 225 256 5 256 289 6 289 324 7 324 361 8 361 400 9 400 NA> # regress z on lag(z, 1:2) using dyn package > library(dyn) > dyn$lm(z ~ lag(z, 1:2))Call: lm(formula = dyn(z ~ lag(z, 1:2))) Coefficients: (Intercept) lag(z, 1:2)1 lag(z, 1:2)2 2 2 -1 # as a workaround one could convert to zoo and back> x <- ts((11:20)^2) > as.ts(lag(as.zoo(x), 1:2))Time Series: Start = 1 End = 9 Frequency = 1 lag1 lag2 1 144 169 2 169 196 3 196 225 4 225 256 5 256 289 6 289 324 7 324 361 8 361 400 9 400 NA>