The R Project SVN R

Rev

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

Rev 31908 Rev 32873
Line 32... Line 32...
32
    checkArity(op, args);
32
    checkArity(op, args);
33
 
33
 
34
    x = CAR(args);
34
    x = CAR(args);
35
    f = CADR(args);
35
    f = CADR(args);
36
    if (!isVector(x))
36
    if (!isVector(x))
37
	errorcall(call, "first argument must be a vector");
37
	errorcall(call, _("first argument must be a vector"));
38
    if (!isFactor(f))
38
    if (!isFactor(f))
39
	errorcall(call, "second argument must be a factor");
39
	errorcall(call, _("second argument must be a factor"));
40
    nlevs = nlevels(f);
40
    nlevs = nlevels(f);
41
    nfac = LENGTH(CADR(args));
41
    nfac = LENGTH(CADR(args));
42
    nobs = LENGTH(CAR(args));
42
    nobs = LENGTH(CAR(args));
43
    if (nobs <= 0)
43
    if (nobs <= 0)
44
	return R_NilValue;
44
	return R_NilValue;
45
    if (nfac <= 0)
45
    if (nfac <= 0)
46
	errorcall(call, "Group length is 0 but data length > 0");
46
	errorcall(call, _("Group length is 0 but data length > 0"));
47
    if (nobs % nfac != 0)
47
    if (nobs % nfac != 0)
48
	warningcall(call, "data length is not a multiple of split variable");
48
	warningcall(call, _("data length is not a multiple of split variable"));
49
    nm = getAttrib(x, R_NamesSymbol);
49
    nm = getAttrib(x, R_NamesSymbol);
50
    have_names = nm != R_NilValue;
50
    have_names = nm != R_NilValue;
51
    PROTECT(counts = allocVector(INTSXP, nlevs));
51
    PROTECT(counts = allocVector(INTSXP, nlevs));
52
    for (i = 0; i < nlevs; i++)
52
    for (i = 0; i < nlevs; i++)
53
	INTEGER(counts)[i] = 0;
53
	INTEGER(counts)[i] = 0;