The R Project SVN R

Rev

Rev 10960 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10960 Rev 19500
1
/*
1
/*
2
 *  R : A Computer Langage for Statistical Data Analysis
2
 *  R : A Computer Langage for Statistical Data Analysis
3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
4
 *  Copyright (C) 1999        The R Development Core Team
4
 *  Copyright (C) 1999        The R Development Core Team
5
 *
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
9
 *  (at your option) any later version.
10
 *
10
 *
11
 *  This program is distributed in the hope that it will be useful,
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
14
 *  GNU General Public License for more details.
15
 *
15
 *
16
 *  You should have received a copy of the GNU General Public License
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
19
 */
20
 
20
 
21
/* Factor Tabulation */
21
/* Factor Tabulation */
22
 
22
 
23
#ifdef HAVE_CONFIG_H
23
#ifdef HAVE_CONFIG_H
24
#include <config.h>
24
#include <config.h>
25
#endif
25
#endif
26
 
26
 
27
#include "R_ext/Arith.h"
27
#include <R_ext/Arith.h>
28
#include "R_ext/Applic.h"
28
#include <R_ext/Applic.h>
29
 
29
 
30
void R_tabulate(int *x, int *n, int *nbin, int *ans)
30
void R_tabulate(int *x, int *n, int *nbin, int *ans)
31
{
31
{
32
    int i;
32
    int i;
33
    if(*n < 1) return;
33
    if(*n < 1) return;
34
    for(i = 0 ; i < *n ; i++)
34
    for(i = 0 ; i < *n ; i++)
35
	if(x[i] != R_NaInt && x[i] > 0 && x[i] <= *nbin)
35
	if(x[i] != R_NaInt && x[i] > 0 && x[i] <= *nbin)
36
	    ans[x[i] - 1]++;
36
	    ans[x[i] - 1]++;
37
}
37
}