Re: [R] Error in match.fun(f) : object 'x' not found

2017-02-21 Thread peter dalgaard
The curve() function is being (overly?) clever in allowing nonstandard evaluation to let you specify an expression for the function argument. For integrate(), you need to go the standard way and set up an actual function of 1 argument and pass that. It's not all that hard: > f <- function(x)

Re: [R] Error in match.fun(f) : object 'x' not found

2017-02-21 Thread Uwe Ligges
On 21.02.2017 18:29, C W wrote: Dear R list, I am having a little trouble understanding the R code. I want to compute expectation of normal pdf. I did the following: integrate(x*dnorm(x, rate=1), -Inf, Inf) integrate needs a function as first argument, hence: integrate(function(x)

[R] Error in match.fun(f) : object 'x' not found

2017-02-21 Thread C W
Dear R list, I am having a little trouble understanding the R code. I want to compute expectation of normal pdf. I did the following: integrate(x*dnorm(x, rate=1), -Inf, Inf) Error in match.fun(f) : object 'x' not found If I did this, I get, integrate(dexp(x, rate=1), -Inf, Inf) Error in