The R Project SVN R

Rev

Rev 14357 | Rev 20812 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14357 Rev 20701
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language 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) 2000, 2001	The R Development Core Team.
4
 *  Copyright (C) 2000--2002	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.
Line 26... Line 26...
26
 *
26
 *
27
 *  See ./format.c	 for the  format_FOO_  functions used below.
27
 *  See ./format.c	 for the  format_FOO_  functions used below.
28
 */
28
 */
29
 
29
 
30
 
30
 
31
/*
-
 
32
 *  FIXME: named-dimname printing implemented for integer arrays only
-
 
33
 */
-
 
34
 
-
 
35
#ifdef HAVE_CONFIG_H
31
#ifdef HAVE_CONFIG_H
36
#include <config.h>
32
#include <config.h>
37
#endif
33
#endif
38
 
34
 
39
#include "Defn.h"
35
#include "Defn.h"
Line 66... Line 62...
66
    x = INTEGER(sx) + offset;
62
    x = INTEGER(sx) + offset;
67
    w = INTEGER(sw);
63
    w = INTEGER(sw);
68
 
64
 
69
    for (j = 0; j < c; j++) {
65
    for (j = 0; j < c; j++) {
70
	formatLogical(&x[j * r], r, &w[j]);
66
	formatLogical(&x[j * r], r, &w[j]);
71
	if (!isNull(cl))
67
	if (!isNull(cl)) {
-
 
68
	    if(STRING_ELT(cl, j) == NA_STRING) 
-
 
69
		clabw = R_print.na_width_noquote;
72
	    clabw = strlen(CHAR(STRING_ELT(cl, j)));
70
	    else clabw = strlen(CHAR(STRING_ELT(cl, j)));
73
	else
71
	} else
74
	    clabw = IndexWidth(j + 1) + 3;
72
	    clabw = IndexWidth(j + 1) + 3;
75
	if (w[j] < clabw)
73
	if (w[j] < clabw)
76
	    w[j] = clabw;
74
	    w[j] = clabw;
77
	w[j] += R_print.gap;
75
	w[j] += R_print.gap;
78
    }
76
    }
Line 133... Line 131...
133
    sw = allocVector(INTSXP, c);
131
    sw = allocVector(INTSXP, c);
134
    x = INTEGER(sx) + offset;
132
    x = INTEGER(sx) + offset;
135
    w = INTEGER(sw);
133
    w = INTEGER(sw);
136
    for (j = 0; j < c; j++) {
134
    for (j = 0; j < c; j++) {
137
	formatInteger(&x[j * r], r, &w[j]);
135
	formatInteger(&x[j * r], r, &w[j]);
138
	if (!isNull(cl))
136
	if (!isNull(cl)) {
-
 
137
	    if(STRING_ELT(cl, j) == NA_STRING) 
-
 
138
		clabw = R_print.na_width_noquote;
139
	    clabw = strlen(CHAR(STRING_ELT(cl, j)));
139
	    else clabw = strlen(CHAR(STRING_ELT(cl, j)));
140
	else
140
	} else
141
	    clabw = IndexWidth(j + 1) + 3;
141
	    clabw = IndexWidth(j + 1) + 3;
142
	if (w[j] < clabw)
142
	if (w[j] < clabw)
143
	    w[j] = clabw;
143
	    w[j] = clabw;
144
	w[j] += R_print.gap;
144
	w[j] += R_print.gap;
145
    }
145
    }
Line 207... Line 207...
207
    e = INTEGER(se);
207
    e = INTEGER(se);
208
    w = INTEGER(sw);
208
    w = INTEGER(sw);
209
 
209
 
210
    for (j = 0; j < c; j++) {
210
    for (j = 0; j < c; j++) {
211
	formatReal(&x[j * r], r, &w[j], &d[j], &e[j], 0);
211
	formatReal(&x[j * r], r, &w[j], &d[j], &e[j], 0);
212
	if (!isNull(cl))
212
	if (!isNull(cl)) {
-
 
213
	    if(STRING_ELT(cl, j) == NA_STRING) 
-
 
214
		clabw = R_print.na_width_noquote;
213
	    clabw = strlen(CHAR(STRING_ELT(cl, j)));
215
	    else clabw = strlen(CHAR(STRING_ELT(cl, j)));
214
	else
216
	} else
215
	    clabw = IndexWidth(j + 1) + 3;
217
	    clabw = IndexWidth(j + 1) + 3;
216
	if (w[j] < clabw)
218
	if (w[j] < clabw)
217
	    w[j] = clabw;
219
	    w[j] = clabw;
218
	w[j] += R_print.gap;
220
	w[j] += R_print.gap;
219
    }
221
    }
Line 293... Line 295...
293
 
295
 
294
    for (j = 0; j < c; j++) {
296
    for (j = 0; j < c; j++) {
295
	formatComplex(&x[j * r], r,
297
	formatComplex(&x[j * r], r,
296
		      &wr[j], &dr[j], &er[j],
298
		      &wr[j], &dr[j], &er[j],
297
		      &wi[j], &di[j], &ei[j], 0);
299
		      &wi[j], &di[j], &ei[j], 0);
298
	if (!isNull(cl))
300
	if (!isNull(cl)) {
-
 
301
	    if(STRING_ELT(cl, j) == NA_STRING) 
-
 
302
		clabw = R_print.na_width_noquote;
299
	    clabw = strlen(CHAR(STRING_ELT(cl, j)));
303
	    else clabw = strlen(CHAR(STRING_ELT(cl, j)));
300
	else
304
	} else
301
	    clabw = IndexWidth(j + 1) + 3;
305
	    clabw = IndexWidth(j + 1) + 3;
302
	w[j] = wr[j] + wi[j] + 2;
306
	w[j] = wr[j] + wi[j] + 2;
303
	if (w[j] < clabw)
307
	if (w[j] < clabw)
304
	    w[j] = clabw;
308
	    w[j] = clabw;
305
	w[j] += R_print.gap;
309
	w[j] += R_print.gap;
Line 370... Line 374...
370
    sw = allocVector(INTSXP, c);
374
    sw = allocVector(INTSXP, c);
371
    x = STRING_PTR(sx)+offset;
375
    x = STRING_PTR(sx)+offset;
372
    w = INTEGER(sw);
376
    w = INTEGER(sw);
373
    for (j = 0; j < c; j++) {
377
    for (j = 0; j < c; j++) {
374
	formatString(&x[j * r], r, &w[j], quote);
378
	formatString(&x[j * r], r, &w[j], quote);
-
 
379
	if (!isNull(cl)) {
-
 
380
	    if(STRING_ELT(cl, j) == NA_STRING) 
-
 
381
		clabw = R_print.na_width_noquote;
375
	if (!isNull(cl)) clabw = strlen(CHAR(STRING_ELT(cl, j)));
382
	    else clabw = strlen(CHAR(STRING_ELT(cl, j)));
-
 
383
	} else
376
	else clabw = IndexWidth(j + 1) + 3;
384
	    clabw = IndexWidth(j + 1) + 3;
377
	if (w[j] < clabw)
385
	if (w[j] < clabw)
378
	    w[j] = clabw;
386
	    w[j] = clabw;
379
    }
387
    }
380
    jmin = 0;
388
    jmin = 0;
381
    jmax = 0;
389
    jmax = 0;