Loading ...
Sorry, an error occurred while loading the content.

opening the CPAN Statistics::Descriptive package?

Expand Messages
  • mmwchang97101
    Hi! I have some limited experience coding in Perl (mostly dealing with spreadsheets and other delimited text files). I m trying to using the
    Message 1 of 1 , Jun 9, 2010
    View Source
    • 0 Attachment
      Hi! I have some limited experience coding in Perl (mostly dealing with spreadsheets and other delimited text files). I'm trying to using the Statistics::Descriptive module, and I keep on getting this error message: "Can't locate Statistics/Descriptive.pm in @INC".

      I'm running the Portable Strawberry Perl (version: 5.10.1). My code is below. I imagine there are other errors (notably in the last loop where I'm trying to calculate the mean and standard deviation of fish counts using the functions in the Statistics::Descriptive package).

      Sorry if this message is hard to read, and I thank you in advance for your help! I also appreciate any constructive comments about how I should order my posts in the future.

      - Charlotte

      use Statistics;

      open FILEIN, "<PiscoRawData.csv";
      open SPECIES, "<PiscoFishCodes.csv";
      open FILEOUT, ">PiscoGroupedData.csv";

      print FILEOUT "Site,Side,Year,NoTransect,Group,GroupTotal,Avg,SD\n";

      <SPECIES>;
      while (<SPECIES>) {
      chomp;
      ($group,$code) = split(/,/,$_);
      $fishgroup{$code} = $group;
      }
      #std dev across transects
      #avg across transects
      <FILEIN>;
      while (<FILEIN>) {
      chomp;
      ($school,$method,$year,$month,$day,$site,$side,$zone,$level,$transect,$fish,$count,$length,$min,$max,$observer,$depth,$vis) = split(/,/,$_);
      $sitetransyr = join(':',$site,$side,$transect,$year);
      #Get number of fish total seen at each transect for each site in each year. (Haven't figured out how to get this into summary)
      $total{$sitetransyr} += $count;
      #Get number of transects run by site by year
      $notrans{$sitetransyr}++;
      #Reclassfy fish codes into larger groups
      $newgp = $fishgroup{$code};
      #Combine Fish group, site, transect, and year to get the total number of that group seen in each year
      $fishtransyr = join(':',$site,$side,$transect,$year,$newgp);
      $gptranstot{$fishtransyr} += $count;
      #push(@{ $fishes{$fishtransyr} }, $count); NOT NECESSARY because variables of interest are total across each transect, not within a transect.
      }

      for $fishtransyr (keys %gptranstot) {
      #need to make a list out of the totals
      ($site,$side,$transect,$year,$group) = split(/:/,$fishtransyr);
      $fishyr = join(':',$site,$side,$year,$newgp);
      $tot = $gptranstot{$fishtranstot};
      push(@{$fishtot{$fishyr}}, $tot);
      $sitetransyr = join(':',$site,$side,$transect,$year);
      $transyrtot = $total{$sitetransyr};
      $notransyr = $notrans{$sitetransyr};
      #Reclassify the data so that I can get the number of transects run for each site in each year
      $siteyr = join(':',$site,$side,$year);
      $numtranssite{$siteyr} = $notransyr;
      }

      for $fishyr (keys %fishtot) {
      $gpstdev = Statistics::Sparse->new();
      $gpavg = Statistics::Sparse->new();
      $gpsum = Statistics::Sparse->new();
      $gpstdev->standard_deviation(@{$fishtot{$fishyr}});
      $gpavg->mean(@{$fishtot{$fishyr}});
      $gpsum->sum(@{$fishtot{$fishyr}});
      ($site,$side,$year,$group) = split(':',$fishyr);
      $siteyr = join(':',$site,$side,$year);
      $notransect = $numtranssite{$siteyr};
      print FILEOUT "$site,$side,$year,$notransect,$group,$gpsum,$avg,$stdev\n";
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.