Hi again Perl gurus
I've created the following Perl script to generate groups of test (T) and development (D) or "treatment and control" with the flip of a coin so to speak divided according to a list of a fake case Id's. So the first perl script I've written to do the simple task of:
fakeid group
1 T
2 D
3 D
4 T
5 D
6 T
and so on and so forth
My perl script to create that dataset follows:
##creating a random test or development generator
@random = ();
for ($i=1; $i<@fakeids; $i+=2){
$random[$i] = rand();
if ($random[$i]<0.5){
print OUTFILE "$fakeids[$i],T\n$fakeids[$i+1],D\n";
}
else {print OUTFILE "$fakeids[$i],D\n$fakeids[$i+1],T\n";
}
}
Now I want to print a dataset that creates 10 more rows of T's and D's (or how many I may want in the future) lined up next to the fakeid's.
So my new dataset will look like:
fakeid group group group ..............
1 T D D
2 D T T
3 D D T
4 T T D
5 D T D
6 T D T
Does anybody know how I can generate however many groups I want to with different column titles alongside the fakeids?
I keep trying a loop but it doesn't seem to work very well so any help will be muuuch appreciated.
Cheers,
klkot
I've created the following Perl script to generate groups of test (T) and development (D) or "treatment and control" with the flip of a coin so to speak divided according to a list of a fake case Id's. So the first perl script I've written to do the simple task of:
fakeid group
1 T
2 D
3 D
4 T
5 D
6 T
and so on and so forth
My perl script to create that dataset follows:
##creating a random test or development generator
@random = ();
for ($i=1; $i<@fakeids; $i+=2){
$random[$i] = rand();
if ($random[$i]<0.5){
print OUTFILE "$fakeids[$i],T\n$fakeids[$i+1],D\n";
}
else {print OUTFILE "$fakeids[$i],D\n$fakeids[$i+1],T\n";
}
}
Now I want to print a dataset that creates 10 more rows of T's and D's (or how many I may want in the future) lined up next to the fakeid's.
So my new dataset will look like:
fakeid group group group ..............
1 T D D
2 D T T
3 D D T
4 T T D
5 D T D
6 T D T
Does anybody know how I can generate however many groups I want to with different column titles alongside the fakeids?
I keep trying a loop but it doesn't seem to work very well so any help will be muuuch appreciated.
Cheers,
klkot