The R Project SVN R

Rev

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

Rev 42307 Rev 44220
Line 39... Line 39...
39
    if (!isFactor(f))
39
    if (!isFactor(f))
40
	error(_("second argument must be a factor"));
40
	error(_("second argument must be a factor"));
41
    nlevs = nlevels(f);
41
    nlevs = nlevels(f);
42
    nfac = LENGTH(CADR(args));
42
    nfac = LENGTH(CADR(args));
43
    nobs = LENGTH(CAR(args));
43
    nobs = LENGTH(CAR(args));
44
    if (nobs <= 0)
-
 
45
	return R_NilValue;
-
 
46
    if (nfac <= 0)
44
    if (nfac <= 0 && nobs > 0)
47
	error(_("Group length is 0 but data length > 0"));
45
	error(_("Group length is 0 but data length > 0"));
48
    if (nobs % nfac != 0)
46
    if (nfac > 0 && (nobs % nfac) != 0)
49
	warning(_("data length is not a multiple of split variable"));
47
	warning(_("data length is not a multiple of split variable"));
50
    nm = getAttrib(x, R_NamesSymbol);
48
    nm = getAttrib(x, R_NamesSymbol);
51
    have_names = nm != R_NilValue;
49
    have_names = nm != R_NilValue;
52
    PROTECT(counts = allocVector(INTSXP, nlevs));
50
    PROTECT(counts = allocVector(INTSXP, nlevs));
53
    for (i = 0; i < nlevs; i++) INTEGER(counts)[i] = 0;
51
    for (i = 0; i < nlevs; i++) INTEGER(counts)[i] = 0;