[R] Strange problem.
spencer.graves at pdf.com
Tue Sep 2 03:54:06 CEST 2003
Note also the warning: "the condition has length > 1 and only the
first element will be used in: if (n < 9543) 0 else prior(n)/n". The
problem is that "if" is not vectorized: "if(n<9543)" is interpreted as
"if(n<9543)", which then produces a scalar output, 0, which
presumably then generates the error message "x and y lengths differ".
Try "ifelse" instead, so "post" becomes:
ifelse(n < 9543, 0, prior(n)/n)
Then plot(post,1,15000) seemed to work fine for me.
hope this helps. spencer graves
> 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
> + 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.
> Yannong Dong
> R-help at stat.math.ethz.ch mailing list
More information about the R-help