Walmes Marques Zeviani
2010-Feb-17 18:31 UTC
[R] How to provide a result from D(f(x), "x") to a curve(f'(x)) ???
Hi all, I want to provide the result from D() to curve(), because I want to plot the k-th derivative of some functions. Actually, I copy from console the result given by D() and paste inside curve(). With a lot of functions and high degree differentiation this process is tedious. Can I provide directly?? # what I actually have done (very simple function) D(expression(x^3), "x") # copy this result curve(3 * x^2) # paste inside # my failed attempts curve(as.expression(D(expression(x^3), "x"))) curve(as.character(as.expression(D(expression(x^3), "x")))) curve(noquote(as.character(as.expression(D(expression(x^3), "x"))))) Thanks in advance. Walmes Zeviani, Brasil. _________________________________________________________________ Quer deixar seus vídeos mais divertidos? Com o Movie Maker isso fica fácil. ndows Live:Dicas - Movie Maker:Hotmail:Tagline:1x1:Titulo Legendas Creditos [[alternative HTML version deleted]]
Gabor Grothendieck
2010-Feb-17 18:48 UTC
[R] How to provide a result from D(f(x), "x") to a curve(f'(x)) ???
Try this: do.call(curve, list(D(expression(x^3), "x"))) On Wed, Feb 17, 2010 at 1:31 PM, Walmes Marques Zeviani <walmeszeviani at hotmail.com> wrote:> > Hi all, > > I want to provide the result from D() to curve(), because I want to plot the k-th derivative of some functions. Actually, I copy from console the result given by D() and paste inside curve(). With a lot of functions and high degree differentiation this process is tedious. Can I provide directly?? > > # what I actually have done (very simple function) > D(expression(x^3), "x") # copy this result > curve(3 * x^2) # paste inside > > # my failed attempts > curve(as.expression(D(expression(x^3), "x"))) > curve(as.character(as.expression(D(expression(x^3), "x")))) > curve(noquote(as.character(as.expression(D(expression(x^3), "x"))))) > > Thanks in advance. > Walmes Zeviani, Brasil. > _________________________________________________________________ > Quer deixar seus v?deos mais divertidos? Com o Movie Maker isso fica f?cil. > > ndows Live:Dicas - Movie Maker:Hotmail:Tagline:1x1:Titulo Legendas Creditos > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >
Greg Snow
2010-Feb-17 20:17 UTC
[R] How to provide a result from D(f(x), "x") to a curve(f'(x)) ???
Try this:> tmp <- as.function(list(x=NULL, D( expression( x^3 ), 'x' ) ) ) > curve(tmp)-- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Walmes Marques Zeviani > Sent: Wednesday, February 17, 2010 11:32 AM > To: r-help at r-project.org > Subject: [R] How to provide a result from D(f(x), "x") to a > curve(f'(x)) ??? > > > Hi all, > > I want to provide the result from D() to curve(), because I want to > plot the k-th derivative of some functions. Actually, I copy from > console the result given by D() and paste inside curve(). With a lot of > functions and high degree differentiation this process is tedious. Can > I provide directly?? > > # what I actually have done (very simple function) > D(expression(x^3), "x") # copy this result > curve(3 * x^2) # paste inside > > # my failed attempts > curve(as.expression(D(expression(x^3), "x"))) > curve(as.character(as.expression(D(expression(x^3), "x")))) > curve(noquote(as.character(as.expression(D(expression(x^3), "x"))))) > > Thanks in advance. > Walmes Zeviani, Brasil. > _________________________________________________________________ > Quer deixar seus v?deos mais divertidos? Com o Movie Maker isso fica > f?cil. > > ndows Live:Dicas - Movie Maker:Hotmail:Tagline:1x1:Titulo Legendas > Creditos > [[alternative HTML version deleted]]