[R] Help deeded: Does a R graphical function return something special?
jim holtman
jholtman at gmail.com
Fri Oct 19 23:04:21 CEST 2007
What exactly are you trying to determine? You can look at the help
page for a function to see what, if any, value is returned.
If you are 'try'ing to catch an error, then the following might help:
> x <- plot(0)
> x
NULL
> x <- plot()
Error in plot() : argument "x" is missing, with no default
> x
NULL
> str(x)
NULL
> x <- try(plot())
Error in plot() : argument "x" is missing, with no default
> str(x)
Class 'try-error' chr "Error in plot() : argument \"x\" is missing,
with no default\n"
>
What you want to do to see if there is an error is to:
if (class(x) =='try-error').....
this will do it. You can not just check the 'value'.
On 10/19/07, HU,ZHENGJUN <hhu at ufl.edu> wrote:
> Hi All,
>
> When I tried to catch a returned value from a R graphical
> function or command (e.g., plot, lines, points, abline, title,
> xyplot, etc.), I always get a NULL value if it is executed
> correctly. For example:
> x <- c(1,2,3,4,5,9,13,19,36)
> plot.Comm <- plot(x) # plot.Comm <- try(eval(plot(x)))
>
> then plot.Comm has a NULL value. Obviously, this is not a good way
> to check if or not it is a graphical function or command since
> plot.Comm <- NULL also lets plot.Comm be NULL.
>
> Does anyone knows:
>
> (1) that a R graphical function or command (e.g., plot, lines,
> points, abline, title, xyplot, etc.) could return something
> special if it is run correctly, which is different from those
> returned from executing any R non-graphical functions or
> commands?
>
> (2) that there is an easy way for a R programmer to know that a R
> function or command is a graphical one before executing it?
>
> Thank you very much for the help in advance.
> Have a good weekend!
> Howard
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list