[ESS] R's scan function and ESS's refusal to send a blank line from code to *R*

Paul Johnson pauljohn32 at gmail.com
Fri Dec 2 20:15:22 CET 2011

Greetings in ESS land:

Last year, I mentioned (here) a problem running the help examples in
the sem package. At that time, I thought the problem was peculiar to
sem, but I've just checked with John Fox and he said no, he didn't
change the R prompt.  He uses R's scan function.  So I think that puts
the "problem" back in the ESS court.

What's wrong is that when you send R into a "scan" mode, you can't get
out of it from ESS the R code file.

Put this in an R file, and try to step through it line by line with ESS:

x <- scan()
1 2 3
4 5 6 7
8 9

You send the 8 9 over, and then "next" command does nothing. There's
nothing there, that's logical, I suppose.

ESS won't send a "blank line" from the R script to the R session, so
the *R* process is "stuck" there until user goes to the *R* terminal
and manually hits enter.

If Emacs/ESS were sending the empty lines through properly,  the scan
would know work is finished. As John said to me, it should finish like

x <- scan()
> 1: 1 2 3
> 4: 4 5 6 7
> 8: 8 9
> 10:
> Read 9 items

I'm using Debian Linux, Emacs 23.3.1 and ESS 5.14, in case that matters.

I've tested this with RStudio and it does not have the same trouble,
it will send the blank line to *R* and the process moves on.

What do you think?

Here's the 'real life' example from the sem package help file

model.dhp <- specifyModel()
    RParAsp  -> RGenAsp, gam11,  NA
    RIQ      -> RGenAsp, gam12,  NA
    RSES     -> RGenAsp, gam13,  NA
    FSES     -> RGenAsp, gam14,  NA
    RSES     -> FGenAsp, gam23,  NA
    FSES     -> FGenAsp, gam24,  NA
    FIQ      -> FGenAsp, gam25,  NA
    FParAsp  -> FGenAsp, gam26,  NA
    FGenAsp  -> RGenAsp, beta12, NA
    RGenAsp  -> FGenAsp, beta21, NA
    RGenAsp  -> ROccAsp,  NA,     1
    RGenAsp  -> REdAsp,  lam21,  NA
    FGenAsp  -> FOccAsp,  NA,     1
    FGenAsp  -> FEdAsp,  lam42,  NA
    RGenAsp <-> RGenAsp, ps11,   NA
    FGenAsp <-> FGenAsp, ps22,   NA
    RGenAsp <-> FGenAsp, ps12,   NA
    ROccAsp <-> ROccAsp, theta1, NA
    REdAsp  <-> REdAsp,  theta2, NA
    FOccAsp <-> FOccAsp, theta3, NA
    FEdAsp  <-> FEdAsp,  theta4, NA

Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

More information about the ESS-help mailing list