[R] stop further sourcing of an R file

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Fri Nov 14 00:04:11 CET 2003


q() will terminate the entire R session.

I suspect what Ramakrishna wants is to set a break-point
in a source file, so as to just read in part of it, and
then continue in the R session with other things.

Though not what it's intended for, 'break' will do the job.

E.g. if test.R contains

  x<-pi*0.01*(0:200);
  plot(x,sin(x))
  break
  plot(x,cos(x))

then after

  source("test.R")

R will plot the sine curve, but not the cosine curve, exiting
at 'break' with the message

  No loop to break from, jumping to top level

and the R session will still be intact, including any variables
created in the script.

Ted.

On 13-Nov-03 Giovanni Petris wrote:
> 
> q()
> 
> 
>> Date: Thu, 13 Nov 2003 13:52:16 -0700 (MST)
>> From: "U.Ramakrishna" <ramakrsn at CS.ColoState.EDU>
>> Sender: r-help-bounces at stat.math.ethz.ch
>> Precedence: list
>> 
>> Hello,
>> Thanks to people who responded to previous mail!
>> 
>> Is there a way in which we can stop further sourcing
>> of an R file? i.e., i am sourcing an R file and keep
>> an equivalent of 'exit' in it and run the code till that point?




More information about the R-help mailing list