Reputation: 3
I'm baffled why #1 would work while #2 wouldn't?
x=rnorm(100);curve(dnorm(x))
y=rnorm(100);curve(dnorm(y))
Error in curve(dnorm(y)) : 'expr' must be a function, or a call or an expression containing 'x'
Upvotes: 0
Views: 170
Reputation: 226077
Because curve()
is somewhat magic and by default requires an expression written as a function of x (literally): from ?curve
.
expr: The name of a function, or a call or an expression written as a function of ‘x’ which will evaluate to an object of the same length as ‘x’.
You could use
curve(dnorm(y),xname="y")
I have to warn you that the x
and y
values you are defining via rnorm()
in your code are being ignored completely. (You could edit your question to explain better what you're trying to do ...)
Upvotes: 1