[R] Package pixmap breaks try() under circumstances
Roger Bivand
Roger.Bivand at nhh.no
Wed Feb 23 10:43:09 CET 2005
On Wed, 23 Feb 2005, Christian Lederer wrote:
>
> Dear R users,
>
> in some circumstances, try() shows a strange behaviour,
> when the pixmap package is loaded.
>
> The following piece of code works as expected, if it is
> either sourced in an interactive session or invoked via
> R CMD BATCH (the try-error is printed).
>
> However, if i invoke R using ``R --vanilla < source.R'',
> the execution halts (without printing the try-error).
>
> # source.R
> library(pixmap)
> x <- numeric()
> y <- numeric()
> result <- try(plot(lm(x~y)))
> print(result)
>
> If i don't use library(pixmap), than also R --vanilla < source.R
> works as expected.
>
> This happens with R-2.0.1 and pixmap-0.4.2 under SuSE 9.2.
But this does work as expected in your setting:
library(pixmap)
x <- numeric()
y <- numeric()
result <- try(lm(x~y))
#result <- try(plot(lm(x~y)))
print(result)
res1 <- try(plot(result))
print(res1)
The failed lm() in your version seems to be muddling plot(), and the try()
is on the plot(), not the lm(). Without pixmap present:
> getAnywhere("plot")
A single object matching 'plot' was found
It was found in the following places
package:graphics
namespace:graphics
with value
...
With pixmap:
> getAnywhere("plot")
2 differing objects matching 'plot' were found
in the following places
package:pixmap
package:graphics
namespace:graphics
Use [] to view one of them
This also works:
library(pixmap)
x <- numeric()
y <- numeric()
result <- try(plot(try(lm(x~y))))
print(result)
Hope this helps.
>
> Christian :-(
>
> P.S.
> The reason for preferring R --vanilla script.R over R CMD BATCH is,
> that i have to produce png images for a server and want to avoid
> the bitmap device for performance reasons.
> With R --vanilla < script.R, this is possible, using the xvnc
> virtual X server.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
More information about the R-help
mailing list