On 5/28/2009 8:58 AM, Mario Valle wrote:
Good morning!
Which is the preferred method to leave a sourced script and returning back to the 
'>' prompt?

For example I search for certain files to be processed, but nothing should be 
done if they
are not present. Normally I do in my script:
f<-dir(pattern="qq")
if(length(f) > 0) {
    ...process file list...
}
# script end

But I don't like those {} encompassing the whole script so I'm searching for 
something to
put in place of the '???' here:
f<-dir(pattern="qq")
if(length(f) == 0) '???'
...process file list...
# script end

Using stop("No file found", call.=F) works, but the Error message is ugly in 
this case.

Any suggestion?

Put the code in a function, call the function as the last line of the script, and return from the function when you want to exit the script.

Duncan Murdoch

______________________________________________
R-help@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.

Reply via email to