On Mon, Nov 19, 2012 at 10:31 AM, R. Michael Weylandt <
michael.weylandt@gmail.com> wrote:

> On Sunday, November 18, 2012, Rlotus wrote:
>
> > Gives a mistake that "probability" is not found
> >
> > x<- runif(1,0,1)
> > y<-x^5+x^8+(cos(x))^3
> > yrandom<- runif(10,0,3)
> > if (y<yrandom) {probabibility=y/yrandom}
> > area=probability*3
> >
> >
> You're ignoring the warning that's also given. Read ?ifelse and be
> enlightened


In general, yes, but in this particular case the error would be there even
if yrandom had length 1.

The fact that the variable is defined by the wrong name if y<yrandom[1] and
is not defined at all if y>yrandom[1] is more of a problem.


   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

	[[alternative HTML version deleted]]


