Anderson, Walter
2008-Jan-14 19:45 UTC
[R] Need help with xspline error message in R 2.6.1 on Windows XP
I am attempting to generate a series of plots with cubic B-Splines and the code I am using is generating the following error message that I have been unable to resolve. Error in grid.Call.graphics("L_xspline", x$x, x$y, x$shape, x$open, x$arrow, : add_point - reached MAXNUMPTS (25200) This is the code that generates this error. plot.results <- function(dfn) { dt <- read.table(dfn) shp <- rep(1, as.numeric(length(dt$year))) shp[1] <- shp[as.numeric(length(dt$year))] <- 0 grid.rect() pushViewport(plotViewport(c(5.1, 4.1, 4.1, 2.1))) pushViewport(dataViewport(dt$year, dt$mean)) grid.rect() grid.xaxis() grid.yaxis() grid.points(dt$year, dt$mean, pch=16) grid.xspline(dt$year, dt$mean, shape=shp, open=TRUE, gp=gpar(col="red")) popViewport(2) } plot.results("section01_model_results.dat") And here is the data that is being used: year mean 1 2010 6738 2 2015 8793 3 2020 11699 4 2025 15951 5 2030 22492 6 2035 33289 7 2040 52917 I have tried changing the values in the shape vector and have noticed that a value of 0 does not generate the error; however, it also does not plot a line or curve. I have also tried values for the shape vector of -1, 0.1, 0.2, and 0.5. I think my problem may be unit related, but am unclear how to specify that my control points are user units (or to convert user units to what ever xspline might prefer). Walter Anderson
Erik Iverson
2008-Jan-14 20:37 UTC
[R] Need help with xspline error message in R 2.6.1 on Windows XP
Walter, Try adding the argument default.units = "native" to your grid.xspline call. Erik Iverson Anderson, Walter wrote:> I am attempting to generate a series of plots with cubic B-Splines and > the code I am using is generating the following error message that I > have been unable to resolve. > > Error in grid.Call.graphics("L_xspline", x$x, x$y, x$shape, x$open, > x$arrow, : add_point - reached MAXNUMPTS (25200) > > This is the code that generates this error. > > plot.results <- function(dfn) { > dt <- read.table(dfn) > shp <- rep(1, as.numeric(length(dt$year))) > shp[1] <- shp[as.numeric(length(dt$year))] <- 0 > grid.rect() > pushViewport(plotViewport(c(5.1, 4.1, 4.1, 2.1))) > pushViewport(dataViewport(dt$year, dt$mean)) > grid.rect() > grid.xaxis() > grid.yaxis() > grid.points(dt$year, dt$mean, pch=16) > grid.xspline(dt$year, dt$mean, shape=shp, open=TRUE, > gp=gpar(col="red")) > popViewport(2) > } > > plot.results("section01_model_results.dat") > > And here is the data that is being used: > > year mean > 1 2010 6738 > 2 2015 8793 > 3 2020 11699 > 4 2025 15951 > 5 2030 22492 > 6 2035 33289 > 7 2040 52917 > > I have tried changing the values in the shape vector and have noticed > that a value of 0 does not generate the error; however, it also does not > plot a line or curve. I have also tried values for the shape vector of > -1, 0.1, 0.2, and 0.5. > > I think my problem may be unit related, but am unclear how to specify > that my control points are user units (or to convert user units to what > ever xspline might prefer). > > Walter Anderson > > ______________________________________________ > 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.
Anderson, Walter
2008-Jan-14 20:40 UTC
[R] Need help with xspline error message in R 2.6.1 on Windows XP
Erik, That worked perfectly! Thank you very much! Walter Anderson -----Original Message----- From: Erik Iverson Sent: Monday, January 14, 2008 2:37 PM To: Anderson, Walter Cc: r-help at r-project.org Subject: Re: [R] Need help with xspline error message in R 2.6.1 on Windows XP Walter, Try adding the argument default.units = "native" to your grid.xspline call. Erik Iverson