[R] sample() issue

David Winsemius dwinsemius at comcast.net
Mon Dec 20 20:36:53 CET 2010


On Dec 20, 2010, at 2:04 PM, cory n wrote:

>> length(sample(25000, 25000*(1-.55)))
> [1] 11249
>
>> 25000*(1-.55)
> [1] 11250
>
>> length(sample(25000, 11250))
> [1] 11250
>
>> length(sample(25000, 25000*.45))
> [1] 11250
>
> So the question is, why do I get 11249 out of the first command and  
> not
> 11250?  I can't figure this one out.

Read the FAQ:
 > 25000*(1-.55)-11250
[1] -1.818989e-12
 > 25000*(1-.55)< 11250
[1] TRUE

?round
?all.equal
?zapsmall
>


-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list