Re: [R] problem with function "rep"

2008-06-12 Thread Charilaos Skiadas
I believe this might do what you want a bit faster. I replaced the while loop with something that is likely to be faster. I saw no reason for the rounding you were doing, better to use as.integer at the end. test <- function(t){ x <- rexp(t,0.1) while(sum(x) <= t) { x <- c(x, rexp(

Re: [R] problem with function "rep"

2008-06-12 Thread Julien Hunt
Hi I believe this should provide an example of the confusing behavior. Run this with t=100 for example: test=function(t){ x=c() while(sum(x)<=t){ ###I simply generate some numbers from an exponential until the sum of these numbers gets to 100(without loss of generality) x=c(x,round(rexp(1,0.1)

Re: [R] problem with function "rep"

2008-06-12 Thread Erik Iverson
Berwin appears to be correct here. After you do x <- x / 0.0001, I inserted a call to round(x) - x, and received round(x) - x [1] 7.275958e-12 0.00e+00 0.00e+00 This is basically a case of FAQ 7.31. Julien Hunt wrote: Hi I believe this should provide an example of the confusing behav

Re: [R] problem with function "rep"

2008-06-12 Thread Marc Schwartz
on 06/12/2008 09:48 AM 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 ar

Re: [R] problem with function "rep"

2008-06-12 Thread Berwin A Turlach
G'day Julien, On Thu, 12 Jun 2008 16:48:43 +0200 Julien Hunt <[EMAIL PROTECTED]> wrote: > 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. >

Re: [R] problem with function "rep"

2008-06-12 Thread Erik Iverson
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

Re: [R] problem with function "rep"

2008-06-12 Thread Charilaos Skiadas
On Jun 12, 2008, at 10:48 AM, Julien Hunt wrote: Do you need more information on my specific program. Thanks for your time and help, Yes, as the posting guide says, we would probably need a reproducible self-contained example. Emphasis on "reproducible" and "self-contained. Best regards,

[R] problem with function "rep"

2008-06-12 Thread Julien Hunt
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 th