The R Project SVN R

Rev

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

Rev 10172 Rev 12976
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		The R Development Core Team.
4
 *  Copyright (C) 2000, 2001	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 420... Line 420...
420
{
420
{
421
    int r, c;
421
    int r, c;
422
 
422
 
423
    r = INTEGER(dim)[0];
423
    r = INTEGER(dim)[0];
424
    c = INTEGER(dim)[1];
424
    c = INTEGER(dim)[1];
-
 
425
    /* PR#850 */
-
 
426
    if ((rl!=R_NilValue) && (r>length(rl)))
-
 
427
	error("too few row labels");
-
 
428
    if ((cl!=R_NilValue) && (c>length(cl)))
-
 
429
	error("too few column labels");
425
    switch (TYPEOF(x)) {
430
    switch (TYPEOF(x)) {
426
    case LGLSXP:
431
    case LGLSXP:
427
	printLogicalMatrix(x, offset, r, c, rl, cl, rn, cn);
432
	printLogicalMatrix(x, offset, r, c, rl, cl, rn, cn);
428
	break;
433
	break;
429
    case INTSXP:
434
    case INTSXP:
Line 443... Line 448...
443
}
448
}
444
 
449
 
445
static void printArrayGeneral(SEXP x, SEXP dim, int quote, SEXP dimnames)
450
static void printArrayGeneral(SEXP x, SEXP dim, int quote, SEXP dimnames)
446
{
451
{
447
/* == printArray(.) */
452
/* == printArray(.) */
448
    SEXP ii, nn, dn, dnn;
453
    SEXP dn, dnn;
449
    int i, j, k, l, b, nb, ndim;
454
    int i, j, k, l, b, nb, ndim;
450
    int nr, nc;
455
    int nr, nc;
451
    int has_dimnames = 0, has_dnn = 0;
456
    int has_dimnames = 0, has_dnn = 0;
452
    char *rn = NULL, *cn = NULL;
457
    char *rn = NULL, *cn = NULL;
453
 
458
 
Line 459... Line 464...
459
	GetMatrixDimnames(x, &rl, &cl, &rn, &cn);
464
	GetMatrixDimnames(x, &rl, &cl, &rn, &cn);
460
	printMatrix(x, 0, dim, quote, 0, rl, cl, rn, cn);
465
	printMatrix(x, 0, dim, quote, 0, rl, cl, rn, cn);
461
    }
466
    }
462
    else {
467
    else {
463
	SEXP dn0, dn1;
468
	SEXP dn0, dn1;
464
	PROTECT(ii = allocVector(INTSXP, ndim));
-
 
465
	PROTECT(nn = allocVector(INTSXP, ndim));
-
 
466
	nr = INTEGER(dim)[0];
469
	nr = INTEGER(dim)[0];
467
	nc = INTEGER(dim)[1];
470
	nc = INTEGER(dim)[1];
468
	b = nr * nc;
471
	b = nr * nc;
469
	nb = 1;
472
	nb = 1;
470
	for (i = 2 ; i < ndim ; i++)
473
	for (i = 2 ; i < ndim ; i++)
Line 521... Line 524...
521
		printStringMatrix(x, i * b, nr, nc, quote, 0, dn0, dn1, rn, cn);
524
		printStringMatrix(x, i * b, nr, nc, quote, 0, dn0, dn1, rn, cn);
522
		break;
525
		break;
523
	    }
526
	    }
524
	    Rprintf("\n");
527
	    Rprintf("\n");
525
	}
528
	}
526
	UNPROTECT(2);
-
 
527
    }
529
    }
528
}
530
}
529
 
531
 
530
void printArray(SEXP x, SEXP dim, int quote, SEXP dimnames)
532
void printArray(SEXP x, SEXP dim, int quote, SEXP dimnames)
531
{
533
{