[R] how can one break or stop or return from a script?

Stu stu.andrews at gmail.com
Mon Nov 16 22:37:37 CET 2009


Hi,

I am using a script to initialize variables in the global workspace.

Based on some condition, I would like to stop evaluation of a script
sourced on the command-line, without issuing an error.

My current solution is the following hack that uses a repeat { }
statement

----------- init.R -----------
#hack to enable setting of breakpoint
repeat {

...
if (condition) {
    break;
}

...

# remember to break !!
break;
} #end repeat
EOF

Thanks,
- Stu




More information about the R-help mailing list