[R] function rep

Covelli Paolo pcovelli at tele2.it
Fri Apr 9 22:58:09 CEST 2010


Hi,

I've got the following code:

p <- 0.34
pb <- p*100
pr <- (1-p)*100

A <- rep(0,pb)  # a vector with 34 "zeros"
B <- rep(1,pr)   # a vector with 66 "ones"

Now if I type
length(A), R answer correctly 34

but if I type
length(B), R answer 65 instead of 66.

I don't understand why it happens. Can anyone help me? Thanks in  
advance.

Paolo



More information about the R-help mailing list