Re: [Rd] capabilities() and non-catchable messages

From: Henrik Bengtsson <hb_at_maths.lth.se>
Date: Mon 20 Jun 2005 - 15:09:37 GMT

No; I've tried/do that too.

/Henrik

Roger D. Peng wrote:

> Would using 'capture.output()' work for you in this case?
> 
> -roger
> 
> Henrik Bengtsson wrote:
> 

>>Just for the record (not a request for fix) and an ad hoc workaround if
>>anyone needs it:
>>
>>REASON:
>>Running an R script as a plugin on a remote Suse Linux 8.2 with R v2.1.0
>>(2005-04-18), I have noticed that capabilities() generates (to standard
>>error)
>>
>> Xlib: connection to "base:0.0" refused by server
>> Xlib: Client is not authorized to connect to Server
>>
>>which cannot be caught by tryCatch();
>>
>> tryCatch({
>> print(capabilities());
>> }, condition=function(c) {
>> cat("Condition caught:\n");
>> str(c);
>> })
>>
>>because it is not a 'condition' (error or warning).
>>
>>CONTEXT:
>>Since source() calls capabilities("iconv") this messages always show up.
>>My R plugin loads custom code using source() and since the standard
>>error from the plugin is checked for messages, the host system
>>interprets this as if something problematic has occured.
>>
>>WORKAROUND:
>>The workaround that I use now is to redefine capabilities() temporarily
>>(since I do not need "iconv" support):
>>
>> orgCapabilities <- base::capabilities;
>> basePos <- which(search() == "package:base"));
>> assign("capabilities", function(...) FALSE, pos=basePos);
>>
>> source(<my file>)
>>
>> basePos <- which(search() == "package:base"));
>> assign("capabilities", orgCapabilities, pos=basePos);
>> rm(orgCapabilities)
>>
>>Cheers
>>
>>Henrik
>>
>>______________________________________________
>>R-devel@r-project.org mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> 
> 
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
>

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Jun 21 01:17:03 2005

This archive was generated by hypermail 2.1.8 : Mon 24 Oct 2005 - 22:27:20 GMT