[R] Why do i get "Error: unexpected input in "A<-lm(GandW ~ Authocracy, Data)"

William Dunlap wdunlap at tibco.com
Sun Nov 25 23:53:34 CET 2012


The parser errors show the text up to the first character that caused a problem,
and not beyond that.  Hence a misinterpreted "<-" would show something like
   Error: unexpected input in "A<-"
and not, what I saw in your mail:
   Error: unexpected input in "A<-lm(GandW ~ Authocracy)\021"
(Some things in your mail were not copy-and-pasted from R into the mailer, e.g.,
there was a semicolon in the input and a comma in its place in the error report,
so I may be wrong here.)

E.g.,
  > A <- lm(y ~ x) %
  Error: unexpected input in "A <- lm(y ~ x) %"

My mailer (Outlook) shows a 021 character (control-Q) at the end of the quoted  part,
so my guess it that you've somehow put a control-Q in there.  I can recreate this
on Linux by first doing 'stty start <control-V><control-T>' to take away control-Q's
usual meaning (resume output after a control-S pauses it), then entering
  > A <- lm(y ~ x)^Q
  Error: unexpected input in "A <- lm(y ~ x)"
(There was a control-Q at the end of my input, made by typing control-V then control-Q.)
You can get a better look at it if you use tryCatch and call deparse() on the error
message, so the control characters are shown:
  > tryCatch(parse(text="A <- lm(y~x)^Q"), error=function(e)deparse(conditionMessage(e)))
  [1] "\"<text>:1:13: unexpected input\\n1: A <- lm(y~x)\\021\\n               ^\""

Is there any way that you could have put stray control characters into your input?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Barry Rowlingson
> Sent: Sunday, November 25, 2012 5:39 AM
> To: F86
> Cc: r-help at r-project.org
> Subject: Re: [R] Why do i get "Error: unexpected input in "A<-lm(GandW ~ Authocracy,
> Data)"
> 
> On Sun, Nov 25, 2012 at 12:15 PM, F86 <faradj.g at gmail.com> wrote:
> > Dear Bruno,
> >
> > I sitll get this message, even when iam using ","   Error: unexpected input
> > in "A<-lm(GandW ~ Authocracy,Data) "
> >
> 
> You're on a Mac, you say? Try googling for "R unexpected error" - Macs
> do some crazy things:
> 
> http://www.manning-sandbox.com/thread.jspa?threadID=46089
> 
> try it with = instead of <-
> 
> 
> 
> >
> > --
> > View this message in context: http://r.789695.n4.nabble.com/Why-do-i-get-Error-
> unexpected-input-in-A-lm-GandW-Authocracy-Data-tp4650559p4650720.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list