koolreport/statistics

为数据提供各种统计度量

1.2.0 2019-07-01 08:16 UTC

This package is auto-updated.

Last update: 2024-09-07 15:03:04 UTC


README

谈到数据,我们也会谈到统计,因为我们通过统计来了解数据。该 Statistics 包允许您计算数据列的基本和高级统计度量。基本度量可以是 minmaxmeanmedian 等。高级度量例如 lowerQuartilepopStdDeviation 以及其他。

安装

通过下载 .zip 文件

  1. 下载
  2. 解压 zip 文件
  3. statistics 文件夹复制到 koolreport 文件夹中,使其看起来如下
koolreport
├── core
├── statistics

通过 composer

composer require koolreport/statistics

文档

快速入门

在您的报告设置页面中,使用进程 \koolreport\statistics\Statistics,其参数为数组,类型为 '{{statistical measure}}' => '{{array of column names}}'

<?php
//MyReport.php
use \koolreport\statistics\Statistics;

class MyReport extends \koolreport\KoolReport
{
    ...
    function setup()
    {
        $this->src('sales')
        ->pipe(new Statistics(array(
            'min' => array('2003'),
            'max' => array('2003'),
            'mean' => array('2003', '2004'),
            'median' => array('2003', '2004', '{{all}}'),
            'lowerQuartile' => array('2005'),
            'upperQuartile' => array('2005'),
            'meanDeviation' => array('{{all}}'),
            'stdDeviation' => array('{{all}}'),
            'percentile_10' => array('{{all}}'),
            'percentile_90' => array('{{all}}'),
        )))
        ->pipe($this->dataStore('salesYearMonthStatistics'));
    }
}

然后在您的视图中,您可以使用 StatisticsReader 工具提取度量

<?php
    //MyReport.view.php:
    use \koolreport\statistics\StatisticsReader;
    
    $stats = StatisticsReader::read($this->dataStore('salesYearMonthStatistics'));

    echo $stats['min']['2003'];
    echo $stats['median']['2004'];
    echo $stats['percentile_90']['{{all}}'];
?>

属性

该包支持以下统计度量

支持

如果您需要支持,请使用我们的论坛,这样其他人也能从中受益。如果支持请求需要隐私,您可以发送电子邮件至 support@koolreport.com