Never mind, I figured it out. You need to use sapply(), for instance, curve(sapply(x, p), from = 0, to =10)
Thanks all! On Tue, Oct 27, 2015 at 11:14 AM, C W <tmrs...@gmail.com> wrote: > 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]] ______________________________________________ R-help@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.