Ah, thanks. I am new to R and was unaware of the from/to parameters for the plot function. I thought xlim and ylim served that purpose. Thanks again!
-Chad On Tue, Mar 27, 2012 at 3:31 AM, Matthieu Dubois <matth...@gmail.com> wrote: > Dear Chad, > > your problem is linked to (1) the function returning NaNs from x values > greater than 50, and (2) the fact that the function is estimated on a > predefined number of points. > > Calling plot for a function object is basically a wrapper for curve(). Your > function g() is evaluated on the whole xlim domain, which will return NaN > values for x>50 (Try g(60) ). In addition, curve() splits the x interval > (here > from 0 to 60) into a predifined number of points (n=101 is the default, see > help(curve)) at which the function is estimated. In your code, the > function is > estimated at values x <- seq(0, 60, length=101), and g(x) that are not NaN > are > plotted. The largest x value (from the sequence) that doesn't return a NaN > is > max(x[!is.nan(g(x))]), which is 49.8. > > One way to solve it is to explicitly specify the domain used to estimate > the > function, by using the from and to arguments that are passed to curve(): > > #Figure 2, with xlim beyond the radius of the circle > plot(g,axes=F,from=0, to =50, xlim=c(0, 60), ylim=c(0,60)) > axis(1,pos=0) > axis(2,pos=0) > > HTH > > Matthieu > > Matthieu Dubois > Post-doctoral researcher > Psychology Department > Université Libre de Bruxelles > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]]
______________________________________________ R-help@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.