[R] create function to solve derivative

Berend Hasselman bhh at xs4all.nl
Fri Nov 16 10:30:29 CET 2012


On 16-11-2012, at 09:43, e-letter wrote:

> On 16/11/2012, Rolf Turner <rolf.turner at xtra.co.nz> wrote:
>> 
>> Your question makes little sense.  Functions have derivatives --- at
>> least some of them do.  Data sets do not have derivatives.  The
>> functions D(), deriv() etc. work on specified analytic expressions
>> for functions --- data sets do not come into the picture.
>> 
> 
> Is the following procedure correct:
> 
> Plot data from data set.
> 
> Suppose the resultant graph was linear. The function could be y=mx+c,
> so the R function 'lm' could be applied to fit a linear line.
> 
> The example in the manual for the help file '?D' shows:
> 
> dx2x <- deriv(~ x^2, "x") ; dx2x
> 
> So for this example it would be correct to write:
> 
> functionname<-deriv(~mx+c,"x");dx2x
> 
> What is the significance of ';dx2x'? It would be appreciated to be
> referred to the relevant manual sections, thanks.

Manual "Introduction to R" (http://cran.r-project.org/doc/manuals/r-release/R-intro.html) 
section 2.1 "Vectors and assignment"
in particular the sentence:  "If an expression is used as a complete command, the value is printed and lost"

Berend




More information about the R-help mailing list