[R] How to use curve() with two parameters in the function
C W
tmrsg11 at gmail.com
Tue Oct 27 16:14:16 CET 2015
Dear R list,
I am trying to plot the curve of a function.
Here's the R code:
library(mvtnorm)
p <- function(x, mu){
mu <- c(mu, 0)
dmvnorm(c(x, 1), mu, diag(2))
}
> curve(p(x, 2), from = 0, to =1)
Error in dmvnorm(c(x, 1), mu, diag(2)) :
mean and sigma have non-conforming size
I think my matrix probably have different size inside curve(), maybe I need
to use apply()? I am not sure.
Thanks so much!
[[alternative HTML version deleted]]
More information about the R-help
mailing list