Hello, I don't understand the description / help-text for the numericDeriv() function. Why is there a new environment used? And what is meant with an environment here? Is it similar or the same as a local workspace, like an environment in functional languages? And why is it needed here? numericDeriv could just calculate the difference bewtween two values and divide this difference by the distance (which is one normally, but maybe in timeseries is a different value. Can you please elaborate on that function? Thanks In Advance, Oliver
On Sun, Oct 12, 2008 at 7:24 AM, Oliver Bandel <oliver at first.in-berlin.de> wrote:> Hello, > > > I don't understand the description / help-text for the > numericDeriv() function. > > Why is there a new environment used? > > And what is meant with an environment here??environment or socserv.mcmaster.ca/jfox/Books/Companion/appendix-scope.pdf> Is it similar or the same as a local workspace, > like an environment in functional languages? > > And why is it needed here? > > numericDeriv could just calculate the difference bewtween two > values and divide this difference by the distance (which is one > normally, > but maybe in timeseries is a different value.The input to numericDeriv is not values but an expression. See the Examples section at the end of ?numericDeriv The expression given as the first arg ultimately needs to be evaluated at a value so it needs to know where to find that value. Note that it defaults to the caller's environment so we can leave that argument out if the variable is known to be there: X <- 3 numericDeriv(quote(X^2), "X")> > Can you please elaborate on that function? > > Thanks In Advance, > Oliver > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
?deltat On Sun, Oct 12, 2008 at 9:45 AM, Oliver Bandel <oliver at first.in-berlin.de> wrote:> Zitat von Gabor Grothendieck <ggrothendieck at gmail.com>: > >> If you simply want successive differences use diff: >> >> x <- seq(4)^2 >> diff(x) >> >> tx <- ts(x) >> diff(tx) > [...] > > Oh, cool, thanks. > > But what about diff / delta_t ? > > Do I have to calculate it by my own, or is there > already a function for making a difference-qoutient? > > This would be fine to have, because for example > coming from space vs. time to velocity vs. time > and acceleration vs. time (and further derivatives) > are also a time-series. > > The possibility of using the advantages of the time series class here, > would be fine. > > > Ciao, > Oliver >