Try "ifelse" instead, so "post" becomes:
post<-function(n){ ifelse(n < 9543, 0, prior(n)/n) }
Then plot(post,1,15000) seemed to work fine for me.
hope this helps. spencer graves
Yannong.Dong-1 wrote:
Hi, everyone, I am a new user of R. Recently, I tried the following commands, but couldn't make them work. If any one of you has some ideas about it, please help me. The commands are
std<-1000 mean<-8000 prior<-function(n){1/(sqrt(2*pi)*std)*exp(-1.0*(n-mean)^2/(2*std^2))} plot(prior,1,15000) post<-function(n){
+ if(n < 9543) + 0
+ else
+ prior(n)/n
+ }
plot(post,1,15000) # This command didn't work. The error message is " x and y lengths differ "
I was really confused about it because the first function "prior" can work well. I think I must make something wrong stupidly, but could not find it. If you can help me about it, it would be very helpful. Thanx a lot in advance.
Rgds, Yannong Dong
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help