> On Oct 1, 2016, at 7:45 AM, L... L... <mar.lamack at hotmail.com>
wrote:
>
> Dear all, I have the following variables:
> fc <- quote(sqrt(2) * pi ^ (-0.1e1 / 0.2e1) * (x / theta) ^ alpha *
alpha / x * exp(-(x / theta) ^ (2 * alpha) / 2))
> and
> d2 <- D(D(fc, "alpha"), "alpha")
> I would like to create a function formed by the product of fc and d2. I
tried:
> fcd2 <- function(x) {}
> body(fcd2) <- c(d2, "*", fc)
Try instead using bquote to get an expression object:
> bquote( .(fc) * .(d2) )
sqrt(2) * pi^(-1/2) * (x/theta)^alpha * alpha/x * exp(-(x/theta)^(2 *
alpha)/2) * ((sqrt(2) * pi^(-1/2) * ((x/theta)^alpha * log((x/theta)) *
log((x/theta))) * alpha + sqrt(2) * pi^(-1/2) * ((x/theta)^alpha *
log((x/theta))) + sqrt(2) * pi^(-1/2) * ((x/theta)^alpha *
log((x/theta))))/x * exp(-(x/theta)^(2 * alpha)/2) - (sqrt(2) *
pi^(-1/2) * ((x/theta)^alpha * log((x/theta))) * alpha +
sqrt(2) * pi^(-1/2) * (x/theta)^alpha)/x * (exp(-(x/theta)^(2 *
alpha)/2) * ((x/theta)^(2 * alpha) * (log((x/theta)) * 2)/2)) -
((sqrt(2) * pi^(-1/2) * ((x/theta)^alpha * log((x/theta))) *
alpha + sqrt(2) * pi^(-1/2) * (x/theta)^alpha)/x * (exp(-(x/theta)^(2 *
alpha)/2) * ((x/theta)^(2 * alpha) * (log((x/theta)) *
2)/2)) + sqrt(2) * pi^(-1/2) * (x/theta)^alpha * alpha/x *
(exp(-(x/theta)^(2 * alpha)/2) * ((x/theta)^(2 * alpha) *
(log((x/theta)) * 2) * (log((x/theta)) * 2)/2) -
exp(-(x/theta)^(2 * alpha)/2) * ((x/theta)^(2 * alpha) *
(log((x/theta)) * 2)/2) * ((x/theta)^(2 * alpha) *
(log((x/theta)) * 2)/2))))
> fcd2 <- function(x) {}
> body(fcd2) <- bquote( .(fc) * .(d2) )
> fcd2
function (x)
sqrt(2) * pi^(-1/2) * (x/theta)^alpha * alpha/x * exp(-(x/theta)^(2 *
alpha)/2) * ((sqrt(2) * pi^(-1/2) * ((x/theta)^alpha * log((x/theta)) *
log((x/theta))) * alpha + sqrt(2) * pi^(-1/2) * ((x/theta)^alpha *
log((x/theta))) + sqrt(2) * pi^(-1/2) * ((x/theta)^alpha *
log((x/theta))))/x * exp(-(x/theta)^(2 * alpha)/2) - (sqrt(2) *
pi^(-1/2) * ((x/theta)^alpha * log((x/theta))) * alpha +
sqrt(2) * pi^(-1/2) * (x/theta)^alpha)/x * (exp(-(x/theta)^(2 *
alpha)/2) * ((x/theta)^(2 * alpha) * (log((x/theta)) * 2)/2)) -
((sqrt(2) * pi^(-1/2) * ((x/theta)^alpha * log((x/theta))) *
alpha + sqrt(2) * pi^(-1/2) * (x/theta)^alpha)/x * (exp(-(x/theta)^(2 *
alpha)/2) * ((x/theta)^(2 * alpha) * (log((x/theta)) *
2)/2)) + sqrt(2) * pi^(-1/2) * (x/theta)^alpha * alpha/x *
(exp(-(x/theta)^(2 * alpha)/2) * ((x/theta)^(2 * alpha) *
(log((x/theta)) * 2) * (log((x/theta)) * 2)/2) -
exp(-(x/theta)^(2 * alpha)/2) * ((x/theta)^(2 * alpha) *
(log((x/theta)) * 2)/2) * ((x/theta)^(2 * alpha) *
(log((x/theta)) * 2)/2))))
> but I did not succeed. Any suggestion is welcome.
> Best regards
> ML
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
David Winsemius
Alameda, CA, USA