Re: [R] Stderr

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Thu, 10 Apr 2008 11:33:40 +0200

Patricia García wrote:
> Hi,
>
> sorry for the last sentence, i was trying to make a generic statement by
> writing "function"
> So the code has to be:
>
> # Save error mesage:
> error1 <- file("error1.txt", open="wt")
> sink(error1, type="message")
> experiment <- somefunction(data)
>
> (I mean no matter what function is...)

So you want to implement error handling for function somefunction()?

> error1 is not a variable, y can't watch what contains, it is only the
> definition of a file....

No, error1 is an *object* that contains information about the opened connection to the file.

> What i wanted was in fact to create a variable with the error message, I can
> do it of course by reading the file, but my question is about doing it
> directly.

As I already said in my former mail, error handling is available, please read ?try.

Uwe Ligges

> Thanks
>
>
>
> 2008/4/10, Uwe Ligges <ligges_at_statistik.tu-dortmund.de>:

>>
>>
>> Patricia García wrote:
>>
>>> Hi everyone,
>>>
>>> I need to get an error message as an object in the std output console. I
>>> can
>>> get it as a file with the following instructions:
>>>
>>> # Save error mesage:
>>>    error1  <-  file("error1.txt", open="wt")
>>>    sink(error1, type="message")
>>>    experiment <- function(data)
>>>
>>>
>>> With this, the error messages get saved in the file, but i need them as
>>> object in order to work with it in the console.
>>>
>>
>> I'm not sure what you are going to do, note that the last line contains an
>> incomplete statement...
>>
>> If you want an object: you already have got the object error1 ...
>>
>> If you want error handling facilities, see ?try and its "See Also"
>> section.
>>
>>
>> Uwe Ligges
>>
>>
>>  Is it possible?
>>> Thanks
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> ______________________________________________
>>> R-help_at_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.
>>>

>

>

R-help_at_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. Received on Thu 10 Apr 2008 - 09:53:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Apr 2008 - 10:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive