The R Project SVN R

Rev

Rev 71432 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 71432 Rev 71433
Line 19... Line 19...
19
    /* Allocate a generic vector to hold the results. */
19
    /* Allocate a generic vector to hold the results. */
20
    /* The i-th element will hold the split-out data */
20
    /* The i-th element will hold the split-out data */
21
    /* for the ith group. */
21
    /* for the ith group. */
22
    PROTECT(vec = allocVector(VECSXP, nlevs));
22
    PROTECT(vec = allocVector(VECSXP, nlevs));
23
    for (R_xlen_t i = 0;  i < nlevs; i++) {
23
    for (R_xlen_t i = 0;  i < nlevs; i++) {
-
 
24
	SET_VECTOR_ELT(vec, i, 
24
	SET_VECTOR_ELT(vec, i, allocVector(TYPEOF(x), _L_INTEG_(counts)[i]));
25
		       allocVector(TYPEOF(x), (_L_int_)_L_INTEG_(counts)[i]));
25
	setAttrib(VECTOR_ELT(vec, i), R_LevelsSymbol,
26
	setAttrib(VECTOR_ELT(vec, i), R_LevelsSymbol,
26
		  getAttrib(x, R_LevelsSymbol));
27
		  getAttrib(x, R_LevelsSymbol));
27
	if(have_names)
28
	if(have_names)
28
	    setAttrib(VECTOR_ELT(vec, i), R_NamesSymbol,
29
	    setAttrib(VECTOR_ELT(vec, i), R_NamesSymbol,
29
		      allocVector(STRSXP, _L_INTEG_(counts)[i]));
30
		      allocVector(STRSXP, (_L_int_)_L_INTEG_(counts)[i]));
30
    }
31
    }
31
    for (int i = 0; i < nlevs; i++) _L_INTEG_(counts)[i] = 0;
32
    for (int i = 0; i < nlevs; i++) _L_INTEG_(counts)[i] = 0;
32
    MOD_ITERATE1(nobs, nfac, i, i1, {
33
    MOD_ITERATE1(nobs, nfac, i, i1, {
33
	int j = INTEGER(f)[i1];
34
	int j = INTEGER(f)[i1];
34
	if (j != NA_INTEGER) {
35
	if (j != NA_INTEGER) {
35
	    _L_int_ k = _L_INTEG_(counts)[j - 1];
36
	    _L_int_ k = (_L_int_)_L_INTEG_(counts)[j - 1];
36
	    switch (TYPEOF(x)) {
37
	    switch (TYPEOF(x)) {
37
	    case LGLSXP:
38
	    case LGLSXP:
38
	    case INTSXP:
39
	    case INTSXP:
39
		INTEGER(VECTOR_ELT(vec, j - 1))[k] = INTEGER(x)[i];
40
		INTEGER(VECTOR_ELT(vec, j - 1))[k] = INTEGER(x)[i];
40
		break;
41
		break;