[Rd] Debug with set.seed()

Patrick Burns pburns at pburns.seanet.com
Sat Jun 2 09:57:22 CEST 2007

I think you will find that 'set.seed' does give you the same
random state each time.  That you don't get the same result
each time implies a bug in your code.  Looking for uninitialized
variables would probably be a good start.  Using valgrind
under Linux would most likely find the error quickly.

Also, using '<<-' is generally a bad idea.

Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
(home of S Poetry and "A Guide for the Unwilling S User")

Tong Wang wrote:

>HI, all
>    I am debugging an R code with dynamically loaded function in it.  It seems set.seed(n) does not give me the same 
>random draws every time.  Could somebody tell me what I should do to get the same outcome verytime ?
>    I am not sure what infomation is relevent to this question , the following is a really scatchy description of the code I wrote.I am using the R-2.4.1 built under Cygwin. OS is WinXP.
>Thanks a lot  for any help.  
>    Myfunction<-function(...) {
>        .......
>        drawsomething<-function(){  out<- .C( "drawit"...........)  
>                                                             var <<- out$var  # assign the outputs}
>        .......
>        for( i in 1 : iter) { .........
>                                    drawsomething()
>                                    .......... }
>       reture( var.stor )     #return stored result
>R-devel at r-project.org mailing list

More information about the R-devel mailing list