The R Project SVN R

Rev

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

Rev 37349 Rev 41686
Line 33... Line 33...
33
    checkArity(op, args);
33
    checkArity(op, args);
34
 
34
 
35
    x = CAR(args);
35
    x = CAR(args);
36
    f = CADR(args);
36
    f = CADR(args);
37
    if (!isVector(x))
37
    if (!isVector(x))
38
	errorcall(call, _("first argument must be a vector"));
38
	error(_("first argument must be a vector"));
39
    if (!isFactor(f))
39
    if (!isFactor(f))
40
	errorcall(call, _("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)
44
    if (nobs <= 0)
45
	return R_NilValue;
45
	return R_NilValue;
46
    if (nfac <= 0)
46
    if (nfac <= 0)
47
	errorcall(call, _("Group length is 0 but data length > 0"));
47
	error(_("Group length is 0 but data length > 0"));
48
    if (nobs % nfac != 0)
48
    if (nobs % nfac != 0)
49
	warningcall(call, _("data length is not a multiple of split variable"));
49
	warning(_("data length is not a multiple of split variable"));
50
    nm = getAttrib(x, R_NamesSymbol);
50
    nm = getAttrib(x, R_NamesSymbol);
51
    have_names = nm != R_NilValue;
51
    have_names = nm != R_NilValue;
52
    PROTECT(counts = allocVector(INTSXP, nlevs));
52
    PROTECT(counts = allocVector(INTSXP, nlevs));
53
    for (i = 0; i < nlevs; i++) INTEGER(counts)[i] = 0;
53
    for (i = 0; i < nlevs; i++) INTEGER(counts)[i] = 0;
54
    for (i = 0; i < nobs; i++) {
54
    for (i = 0; i < nobs; i++) {