p.dalgaard at biostat.ku.dk
2008-Feb-08 14:45 UTC
[Rd] xspline(..., draw=FALSE) fails if there is no open device (PR#10728)
jari.oksanen at oulu.fi wrote:> Full_Name: Jari Oksanen > Version: 2.6.2 RC (2008-02-07 r44369) > OS: Linux > Submission from: (NULL) (130.231.102.145) > > > Even if function xspline() is called with argument draw=3DFALSE, it requires a > graphics device (that it won't use since it was draw=3DFALSE). I run into this > because I intended to use xspline within a function (that does not yet draw: > there is plot method for that), and the function failed when called in a virgin > environment.=20 > > Here is an example in a virgin environemt just after starting R: > > =20 >> out <- xspline(c(0,1,0), c(1,0,1), draw=3DFALSE) >> =20 > Error in xspline(c(0, 1, 0), c(1, 0, 1), draw =3D FALSE) :=20 > plot.new has not been called yet > =20 >> str(out) >> =20 > Error in str(out) : object "out" not found > > This works: > > =20 >> plot(0) >> out <- xspline(c(0,1,0), c(1,0,1), draw=3DFALSE) >> str(out) >> =20 > List of 2 > $ x: num [1:3] 0 1 0 > $ y: num [1:3] 1 0 1 > > This won't: > > =20 >> dev.off() >> =20 > null device=20 > 1=20 > =20 >> xspline(c(0,1,0), c(1,0,1), draw=3DFALSE) >> =20 > Error in xspline(c(0, 1, 0), c(1, 0, 1), draw =3D FALSE) :=20 > plot.new has not been called yet > > R graphics internal are black magic to me. However, it seems that the error > messge comes from function GCheckState(DevDesc *dd) in graphics.c, which is > called by do_xspline(SEXP call, SEXP op, SEXP args, SEXP env) in plot.c even > when xspline was called with draw =3D FALSE (and even before getting the argument > draw into do_xspline). It seems that graphics device is needed somewhere even > with draw =3D FALSE, since moving the GCheckState() test after findig the value > draw, and executing the test only if draw=3DTRUE gave NaN as the numeric output.=20 > > If this is documented behaviour, the documentation escaped my attention and beg > for pardon. It may be useful to add a comment on the help page saying that an > open graphics device is needed even when unused with draw=3DFALSE. > > =20I think the reason is that 2d splines are aspect ratio dependent. =20 There's this loop inside, for (i =3D 0; i < nx; i++) { xx[i] =3D x[i]; yy[i] =3D y[i]; GConvert(&(xx[i]), &(yy[i]), USER, DEVICE, dd); } =20 and that will not work without knowing how to convert to device=20 coordinates. The default for "border" may get you first, though. That=20 seems to be documented incorrectly, by the way. -p> Cheers, Jari Oksanen > > platform =3D i686-pc-linux-gnu > arch =3D i686 > os =3D linux-gnu > system =3D i686, linux-gnu > status =3D RC > major =3D 2 > minor =3D 6.2 > year =3D 2008 > month =3D 02 > day =3D 07 > svn rev =3D 44369 > language =3D R > version.string =3D R version 2.6.2 RC (2008-02-07 r44369) > > Locale: > LC_CTYPE=3Den_GB.UTF-8;LC_NUMERIC=3DC;LC_TIME=3Den_GB.UTF-8;LC_COLLATE=3Den_GB.UTF-8;LC_MONETARY=3Den_GB.UTF-8;LC_MESSAGES=3Den_GB.UTF-8;LC_PAPER=3Den_GB.UTF-8;LC_NAME=3DC;LC_ADDRESS=3DC;LC_TELEPHONE=3DC;LC_MEASUREMENT=3Den_GB.UTF-8;LC_IDENTIFICATION=3DC > > Search Path: > .GlobalEnv, package:stats, package:graphics, package:grDevices, package:utils, > package:datasets, package:methods, Autoloads, package:base > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > =20--=20 O__ ---- Peter Dalgaard =D8ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Maybe Matching Threads
- xspline(..., draw=FALSE) fails if there is no open device (PR#10727)
- xspline, graphical parameters and MAXNUMPTS
- Need help with xspline error message in R 2.6.1 on Windows XP
- installing any package fails using 'install.packages()' (PR#13996)
- Bug in format.default(): na.encode does not have any effect for (PR#12318)