/[pspp]/pspp/src/examine.q
ViewVC logotype

Diff of /pspp/src/examine.q

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by jmd, Tue Jan 18 11:31:45 2005 UTC revision 1.20 by jmd, Tue Jan 18 15:15:12 2005 UTC
# Line 116  static void show_descriptives(struct var Line 116  static void show_descriptives(struct var
116                                struct factor *factor);                                struct factor *factor);
117    
118  static void show_percentiles(struct variable **dependent_var,  static void show_percentiles(struct variable **dependent_var,
119                                int n_dep_var,                               int n_dep_var,
120                                struct factor *factor);                               struct factor *factor);
121    
122    
123    
# Line 151  void factor_calc(struct ccase *c, int ca Line 151  void factor_calc(struct ccase *c, int ca
151  /* Represent a factor as a string, so it can be  /* Represent a factor as a string, so it can be
152     printed in a human readable fashion */     printed in a human readable fashion */
153  const char * factor_to_string(const struct factor *fctr,  const char * factor_to_string(const struct factor *fctr,
154                          struct factor_statistics *fs,                                struct factor_statistics *fs,
155                          const struct variable *var);                                const struct variable *var);
156    
157    
158  /* Represent a factor as a string, so it can be  /* Represent a factor as a string, so it can be
# Line 211  cmd_examine(void) Line 211  cmd_examine(void)
211    multipass_procedure_with_splits (run_examine, &cmd);    multipass_procedure_with_splits (run_examine, &cmd);
212    
213    if ( totals )    if ( totals )
214      free( totals );      {
215          free( totals );
216        }
217        
218    if ( dependent_vars )    if ( dependent_vars )
219      free (dependent_vars);      free (dependent_vars);
# Line 467  xmn_custom_nototal(struct cmd_examine *p Line 469  xmn_custom_nototal(struct cmd_examine *p
469    
470    
471    
472  /* Parser for the variables sub command */  /* Parser for the variables sub command  
473       Returns 1 on success */
474  static int  static int
475  xmn_custom_variables(struct cmd_examine *cmd )  xmn_custom_variables(struct cmd_examine *cmd )
476  {  {
   
477    lex_match('=');    lex_match('=');
478    
479    if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)    if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
480        && token != T_ALL)        && token != T_ALL)
481      return 2;      {
482          return 2;
483        }
484        
485    if (!parse_variables (default_dict, &dependent_vars, &n_dependent_vars,    if (!parse_variables (default_dict, &dependent_vars, &n_dependent_vars,
486                          PV_NO_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH) )                          PV_NO_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH) )
# Line 488  xmn_custom_variables(struct cmd_examine Line 492  xmn_custom_variables(struct cmd_examine
492    assert(n_dependent_vars);    assert(n_dependent_vars);
493    
494    totals = xmalloc( sizeof(struct metrics) * n_dependent_vars);    totals = xmalloc( sizeof(struct metrics) * n_dependent_vars);
   memset ( totals, 0, sizeof(struct metrics) * n_dependent_vars);  
495    
496    if ( lex_match(T_BY))    if ( lex_match(T_BY))
497      {      {
498        return examine_parse_independent_vars(cmd);        int success ;
499          success =  examine_parse_independent_vars(cmd);
500          if ( success != 1 ) {
501            free (dependent_vars);
502            free (totals) ;
503          }
504          return success;
505      }      }
506    
507    return 1;    return 1;
# Line 504  xmn_custom_variables(struct cmd_examine Line 513  xmn_custom_variables(struct cmd_examine
513  static int  static int
514  examine_parse_independent_vars(struct cmd_examine *cmd)  examine_parse_independent_vars(struct cmd_examine *cmd)
515  {  {
516      int success;
517    struct factor *sf = xmalloc(sizeof(struct factor));    struct factor *sf = xmalloc(sizeof(struct factor));
518    
519    if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)    if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
520        && token != T_ALL)        && token != T_ALL)
521      return 2;      {
522          free ( sf ) ;
523          return 2;
524        }
525    
526    
527    sf->indep_var[0] = parse_variable();    sf->indep_var[0] = parse_variable();
# Line 522  examine_parse_independent_vars(struct cm Line 534  examine_parse_independent_vars(struct cm
534    
535        if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)        if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
536            && token != T_ALL)            && token != T_ALL)
537          return 2;          {
538              free ( sf ) ;
539              return 2;
540            }
541    
542        sf->indep_var[1] = parse_variable();        sf->indep_var[1] = parse_variable();
543    
# Line 543  examine_parse_independent_vars(struct cm Line 558  examine_parse_independent_vars(struct cm
558    if ( token == '.' || token == '/' )    if ( token == '.' || token == '/' )
559      return 1;      return 1;
560    
561    return examine_parse_independent_vars(cmd);    success =  examine_parse_independent_vars(cmd);
562      
563      if ( success != 1 )
564        free ( sf ) ;
565    
566      return success;
567  }  }
568    
569    
# Line 795  run_examine(const struct casefile *cf, v Line 815  run_examine(const struct casefile *cf, v
815      {      {
816        int i;        int i;
817        for ( i = 0 ; i < n_dependent_vars ; ++i )        for ( i = 0 ; i < n_dependent_vars ; ++i )
818          metrics_destroy(&totals[i]);          {
819              metrics_destroy(&totals[i]);
820            }
821      }      }
822    
823  }  }
# Line 828  show_summary(struct variable **dependent Line 850  show_summary(struct variable **dependent
850        n_rows = n_dep_var * n_factors ;        n_rows = n_dep_var * n_factors ;
851    
852        if ( fctr->indep_var[1] )        if ( fctr->indep_var[1] )
853            heading_columns = 3;          heading_columns = 3;
854      }      }
855    else    else
856      {      {
# Line 953  show_summary(struct variable **dependent Line 975  show_summary(struct variable **dependent
975                if ( 0 != compare_values(&prev, &(*fs)->id[0],                if ( 0 != compare_values(&prev, &(*fs)->id[0],
976                                         fctr->indep_var[0]->width))                                         fctr->indep_var[0]->width))
977                  {                  {
978                     tab_text (tbl,                    tab_text (tbl,
979                               1,                              1,
980                               (i * n_factors ) + count +                              (i * n_factors ) + count +
981                               heading_rows,                              heading_rows,
982                               TAB_LEFT | TAT_TITLE,                              TAB_LEFT | TAT_TITLE,
983                               value_to_string(&(*fs)->id[0], fctr->indep_var[0])                              value_to_string(&(*fs)->id[0], fctr->indep_var[0])
984                               );                              );
985    
986                     if (fctr->indep_var[1] && count > 0 )                    if (fctr->indep_var[1] && count > 0 )
987                       tab_hline(tbl, TAL_1, 1, n_cols - 1,                      tab_hline(tbl, TAL_1, 1, n_cols - 1,
988                                 (i * n_factors ) + count + heading_rows);                                (i * n_factors ) + count + heading_rows);
989    
990                  }                  }
991                                
# Line 1046  show_extremes(struct variable **dependen Line 1068  show_extremes(struct variable **dependen
1068        n_rows = n_dep_var * 2 * n_extremities * n_factors;        n_rows = n_dep_var * 2 * n_extremities * n_factors;
1069    
1070        if ( fctr->indep_var[1] )        if ( fctr->indep_var[1] )
1071            heading_columns = 3;          heading_columns = 3;
1072      }      }
1073    else    else
1074      {      {
# Line 1223  populate_extremes(struct tab_table *t, Line 1245  populate_extremes(struct tab_table *t,
1245                      cn->num, 8, 0);                      cn->num, 8, 0);
1246    
1247            if ( cn->next )            if ( cn->next )
1248                cn = cn->next;              cn = cn->next;
1249    
1250          }          }
1251    
# Line 1252  populate_extremes(struct tab_table *t, Line 1274  populate_extremes(struct tab_table *t,
1274                      cn->num, 8, 0);                      cn->num, 8, 0);
1275    
1276            if ( cn->next )            if ( cn->next )
1277                cn = cn->next;              cn = cn->next;
1278    
1279          }          }
1280    
# Line 1287  show_descriptives(struct variable **depe Line 1309  show_descriptives(struct variable **depe
1309        n_rows = n_dep_var * n_stat_rows * n_factors;        n_rows = n_dep_var * n_stat_rows * n_factors;
1310    
1311        if ( fctr->indep_var[1] )        if ( fctr->indep_var[1] )
1312            heading_columns = 5;          heading_columns = 5;
1313      }      }
1314    else    else
1315      {      {
# Line 1387  show_descriptives(struct variable **depe Line 1409  show_descriptives(struct variable **depe
1409                            );                            );
1410    
1411                populate_descriptives(tbl, heading_columns - 2,                populate_descriptives(tbl, heading_columns - 2,
1412                                  row, &(*fs)->m[i]);                                      row, &(*fs)->m[i]);
1413    
1414                count++ ;                count++ ;
1415                fs++;                fs++;
# Line 1715  box_plot_group(const struct factor *fctr Line 1737  box_plot_group(const struct factor *fctr
1737            int n_factors = 0;            int n_factors = 0;
1738            int f=0;            int f=0;
1739            for ( fs = fctr->fs ; *fs ; ++fs )            for ( fs = fctr->fs ; *fs ; ++fs )
1740                ++n_factors;              ++n_factors;
1741    
1742            chart_write_title(ch, _("Boxplot of %s vs. %s"),            chart_write_title(ch, _("Boxplot of %s vs. %s"),
1743                              var_to_string(vars[i]), var_to_string(fctr->indep_var[0]) );                              var_to_string(vars[i]), var_to_string(fctr->indep_var[0]) );
# Line 1852  np_plot(const struct metrics *m, const c Line 1874  np_plot(const struct metrics *m, const c
1874  /* Show the percentiles */  /* Show the percentiles */
1875  void  void
1876  show_percentiles(struct variable **dependent_var,  show_percentiles(struct variable **dependent_var,
1877                    int n_dep_var,                   int n_dep_var,
1878                    struct factor *fctr)                   struct factor *fctr)
1879  {  {
1880    struct tab_table *tbl;    struct tab_table *tbl;
1881    int i;    int i;
# Line 1878  show_percentiles(struct variable **depen Line 1900  show_percentiles(struct variable **depen
1900        ptiles = (*fs)->m[0].ptile_hash;        ptiles = (*fs)->m[0].ptile_hash;
1901    
1902        if ( fctr->indep_var[1] )        if ( fctr->indep_var[1] )
1903            n_heading_columns = 4;          n_heading_columns = 4;
1904      }      }
1905    else    else
1906      {      {
# Line 2020  show_percentiles(struct variable **depen Line 2042  show_percentiles(struct variable **depen
2042    
2043    
2044                populate_percentiles(tbl, n_heading_columns - 1,                populate_percentiles(tbl, n_heading_columns - 1,
2045                                  row, &(*fs)->m[i]);                                     row, &(*fs)->m[i]);
2046    
2047    
2048                count++ ;                count++ ;
# Line 2032  show_percentiles(struct variable **depen Line 2054  show_percentiles(struct variable **depen
2054        else        else
2055          {          {
2056            populate_percentiles(tbl, n_heading_columns - 1,            populate_percentiles(tbl, n_heading_columns - 1,
2057                                  i * n_stat_rows * n_factors  + n_heading_rows,                                 i * n_stat_rows * n_factors  + n_heading_rows,
2058                                  &totals[i]);                                 &totals[i]);
2059          }          }
2060    
2061    
# Line 2142  factor_to_string(const struct factor *fc Line 2164  factor_to_string(const struct factor *fc
2164    
2165  const char *  const char *
2166  factor_to_string_concise(const struct factor *fctr,  factor_to_string_concise(const struct factor *fctr,
2167                   struct factor_statistics *fs)                           struct factor_statistics *fs)
2168    
2169  {  {
2170    

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26