I have a dataset of values for variables for subjects. Some subject have
multiple records, requiring an average:
ID Var1 Var2
1 1.0 2.0
1 2.0 1.5
-------------
1 1.5 1.75
If I collect the variables into an array, I can average the contents after I
have processed the entire file. It would seem that I want something like:
my %subjects ;
$subjects{ $ID }{ $var }[ 0 ] = $var1 ;
$subjects{ $ID }{ $var }[ 0 ] = $var2 ;
It does not seem like I could PUSH values onto the array:
push $subject{ $ID }{ $var } , $var1 ;
My first inclination is to use EXISTS and a create a variable intended to
INDEX the array:
my $index ;
if ( ~ exists $subjects{ $ID }{ $var } ) {
$index = 0 ;
} else { $index = $subjects{ $ID }{ $var } )
$subjects{ $ID }{ $var }[ $index ] = $var1 ;
I would appreciate any comments or suggestions concerning this approach.
Thank you,
Kevin
Kevin Viel, PhD
Post-doctoral fellow
Department of Genetics
Southwest Foundation for Biomedical Research
San Antonio, TX 78227
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/