[R] Parse error in xtabs

Andrew Perrin aperrin at socrates.berkeley.edu
Wed Apr 4 03:37:01 CEST 2001


Well, for whatever reason debug() isn't stepping through for me:


> debug(xtabs(cbind(r.logic.interests,
r.logic.morality,r.logic.enlightened, r.logic.capacity,r.logic.mediate)~
grouptype,data=gt))
Error in parse(file, n, text, prompt) : parse error
> traceback()
11: parse(text = x)
10: eval(parse(text = x)[[1]])
9: formula(eval(parse(text = x)[[1]]))
8: switch(mode(x), "NULL" = structure(NULL, class = "formula"), 
       character = formula(eval(parse(text = x)[[1]])), call = eval(x), 
       stop("invalid formula"))
7: formula.default(paste(lhs, "~", rhs))
6: formula(paste(lhs, "~", rhs))
5: fixFormulaObject(tmp)
4: terms.formula(formula)
3: terms(formula)
2: any(attr(terms(formula), "order") > 1)
1: xtabs(cbind(r.logic.interests, r.logic.morality, r.logic.enlightened, 
       r.logic.capacity, r.logic.mediate) ~ grouptype, data = gt)
> 

Interestingly enough, the behavior is the same under R 1.2.2 under
Solaris and linux, but NOT under Windows. I solved the problem for the
short term by save()ing the data and opening it on a Windows machine to do
the analyses. Ugh.

----------------------------------------------------------------------
Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology  
(Soon: Asst Professor of Sociology, U of North Carolina, Chapel Hill)
andrew_perrin at unc.edu - http://www.unc.edu/~aperrin

On 4 Apr 2001, Peter Dalgaard BSA wrote:

> Andrew Perrin <aperrin at socrates.berkeley.edu> writes:
> 
> > Greetings-
> > 
> > Using R 1.2.2 under linux, I get the following:
> > > l.agg<-xtabs(cbind(r.logic.interests, r.logic.morality,
> > +                    r.logic.enlightened, r.logic.capacity,
> > r.logic.mediate)
> > +              ~ grouptype,
> > +              data=gt)
> > Error in parse(file, n, text, prompt) : parse error
> > 
> > 
> > I know the data are structured fine, as I can use all the elements in
> > individual xtabs() calls such as the one below:
> > 
> > > l.agg<-xtabs(cbind(r.logic.morality,r.logic.capacity) ~ grouptype,
> > data=gt)
> > > summary(l.agg)
> > Call:
> > xtabs(formula = cbind(r.logic.morality, r.logic.capacity) ~ grouptype, 
> >     data = gt)
> > Number of cases in table: 693 
> > Number of factors: 2 
> > Test for independence of all factors:
> >         Chisq = 5.447, df = 4, p-value = 0.2444
> > 
> > Any advice?
> 
> You might try debugging it further with traceback() and debug(). It's
> pretty difficult to pinpoint the cause from the information you give.
> 
> In particular, what is in "text" at the point of the crash? My first
> guess was that it was parse having trouble with the argument length,
> but apparently not:
> 
> >  x <- (cbind(r.logic.interests, r.logic.morality,
> +  r.logic.enlightened, r.logic.capacity,
> +  r.logic.mediate) ~grouptype)
> > parse(text=deparse(x))
> expression(cbind(r.logic.interests, r.logic.morality, r.logic.enlightened, 
>     r.logic.capacity, r.logic.mediate) ~ grouptype)
> 
> -- 
>    O__  ---- Peter Dalgaard             Blegdamsvej 3  
>   c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
>  (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list