[R] function rep
Stephan Kolassa
Stephan.Kolassa at gmx.de
Fri Apr 9 23:14:51 CEST 2010
Hi,
this is FAQ 7.31: pb and pr are floating-point numbers that are coerced
to integer for rep(), and this does not always work the way you want.
HTH
Stephan
Covelli Paolo schrieb:
> 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.
>
More information about the R-help
mailing list