[Rd] R GUI API: suggestion for R function to put in there?

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Oct 30 16:33:47 CET 2006


Hi Philippe!

Sorry to break the threading and formatting, I'm not subscribed to r-devel, 
hence just copying from the web archive.

Philippe Grosjean wrote:
>- To know if some R code is complete or is continued to the next line. 
> The following trick was suggested by Peter Dalgaard once, but it is 
> fragile because it depends on the way R prints errors, and that may 
> change in the future:

This is doable in C using R_ParseVector. If you would like to see details, of 
how this is done in RKWard, contact me via private mail.

One problem, however, we did not solve: Is there a way to get at syntax errors 
(if any) from C? parseError () is not exported.

> - To execute R code contained in a string and return the result of this 
> evaluation in a string (including presentation of error messages and 
> warnings) exactly as if this was entered at the prompt.

In RKWard we come close to this using R_ParseVector and some further tricks 
(not quite perfect, however), so again, contact me on this, if you like.
Still, having a more straight-forward way to evaluate a string just as like it 
had been entered on the console would be very nice to have.

> - In the same idea, to write a similar function, but that returns a list 
> of strings, each string being flagged as 'output', 'warning' or 'error'. 
> The succession should correspond to the evaluation (this is especially 
> tricky for warning messages, due to the complex way R handles those 
> warning message.

I very much second this. Note also that I would be nice to catch direct uses 
of REprintf () (which may not neccessarily be a warning or error, but may be 
elegible for special handling in the front-end; hence the suggestion by 
Hadley Wickham does not cover everything I'd like to see covered).
I once made a proposal on how to achieve some of this from C (last public 
message on this was 
https://stat.ethz.ch/pipermail/r-devel/2005-October/035144.html). Patch has 
since been improved 
(http://rkward.sourceforge.net/temp/r_writeerrconsole_v3_updated2.diff), but 
it seems, whenever I send it to Duncan, it happens to be a bad point of time 
for him to review it. Anybody else willing to test this on Windows / help me 
get this to an includable state?

> - To know which objects were changed since a given date, or during last 
> call. This should require a time flag on the variable that contains this 
> object. One particular application is an object explorer that could 
> update information quickly if it could query only those objects that 
> have changed since last process. This topic has already been discussed a 
> couple of times, and no convincing solution has emerged (technical 
> problems), it seems... but it is worth to continue thinking about it.

I've attacked this problem in RKWard very recently (not a full time flag, but 
at least catching all modifications). The approach we use since 0.4.0 is to
1) after each evaluation check for new / removed symbols in .GlobalEnv (not 
very elegant, but good enough)
2) move all symbols in .GlobalEnv to a dedicated environment, and 
in .GlobalEnv replace them with active bindings. Assignments to the symbols 
can now simply be detected via the active binding.
Once again, more details on request. Of course an easier solution would be 
very welcome, but it seems to work pretty well.

Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-devel/attachments/20061030/a1fb6dfc/attachment-0004.bin 


More information about the R-devel mailing list