Here is my best solution so far using $RANDOM in bash
or maybe somebody has "pure R"  solution ?

#!/bin/bash
for i in 1 2; do
p=tmp$i
cat > $p.R << EOF
set.seed($RANDOM)
cat('rnorm(3) =', rnorm(3), '\n')
EOF
nice R CMD BATCH --no-save --no-restore $p.R $p.log &
done
sleep 3
grep rnorm tmp[12].log

Best regards,
Ryszard





Ryszard Czerminski/PH/[EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
06/09/2004 03:24 PM

 
        To:     [EMAIL PROTECTED]
        cc: 
        Subject:        [R] how to initialize random seed properly ?


I want to start R processes on multiple processors from single shell 
script
and I want all of them to have different random seeds.
One way of doing this is

        sleep 2 # (with 'sleep 1' I am often getting the same number)
               ...
        set.seed(unclass(Sys.time()))

Is there a simpler way without a need to sleep between invoking
different R processes ?

Ryszard

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to