[R] problem with function "rep"

Erik Iverson iverson at biostat.wisc.edu
Thu Jun 12 17:01:46 CEST 2008


We need a reproducible example of this to tell you what is going on. 
Find a small example that exhibits the confusing behavior, and share it 
with the list.

Julien Hunt wrote:
> To whom it may concern,
> 
> I am currently writing a program where I need to use function rep.
> The results I get are quite confusing. Given two 
> vectors A and B, I want to replicate a[1] b[1] 
> times, a[2] b[2] times and so on.
> All the entries of vector B are positive integers.
> My problem comes from the fact that if I sum up 
> all the elements of B, I get a certain 
> value  x(for example 10000). And if i calculate 
> the length of the vector obtained after 
> replication, I dont always get x(10000) but 
> sometimes I get x sometimes I get 9999 instead of 10000.
> Has this problem been reported before? Do you 
> need more information on my specific program.
> Thanks for your time and help,
> Best regards,
> 
> Julien Hunt
> 
> Julien Hunt,
> PhD student and teaching assistant,
> Institute of Statistics,
> Université Catholique de Louvain,
> Voie du Roman pays 20
> B-1348 Louvain-La-Neuve,
> Belgium
> 
> E-mail: Julien.Hunt at uclouvain.be
> Tel: +32 10 / 47 94 01
> *****************************************************
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> 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