[R] function rep

Henrique Dallazuanna wwwhsd at gmail.com
Fri Apr 9 23:13:55 CEST 2010


See FAQ "7.31 Why doesn't R think these numbers are equal?"

and try this:

rep(1, ceiling(pr))

On Fri, Apr 9, 2010 at 5:58 PM, Covelli Paolo <pcovelli at tele2.it> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list