Consider the following: plot(0, 0, xlim=c(-10, 10), ylim=c(-50, 50)) lines(c(0,0), (2*c(-pi, pi))^2) I see no line in this plot. R version 2.4.1 (2006-12-18) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" My work around is the following: pi2.2 <- (2*pi)^2 lines(c(0, 0), c(-pi2.2, pi2.2)) Why won't "lines(c(0,0), (2*c(-pi, pi))^2)" work for me? Thanks, Spencer Graves
That's because your "line" is a point. Both components of the y vector are equal. Check your parens. On 1/23/07, Spencer Graves <spencer.graves at pdf.com> wrote:> Consider the following: > > plot(0, 0, xlim=c(-10, 10), ylim=c(-50, 50)) > lines(c(0,0), (2*c(-pi, pi))^2) > > I see no line in this plot. > > R version 2.4.1 (2006-12-18) > i386-pc-mingw32 > > locale: > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United > States.1252;LC_MONETARY=English_United > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" > > My work around is the following: > > pi2.2 <- (2*pi)^2 > lines(c(0, 0), c(-pi2.2, pi2.2)) > > Why won't "lines(c(0,0), (2*c(-pi, pi))^2)" work for me? > Thanks, > Spencer Graves > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >
On Jan 23, 2007, at 10:41 AM, Spencer Graves wrote:> Consider the following: > > plot(0, 0, xlim=c(-10, 10), ylim=c(-50, 50)) > lines(c(0,0), (2*c(-pi, pi))^2) >You are creating a line from point (0,(2*(-pi))^2) to point (0,(2*pi) ^2), however, since (-pi)^2=pi^2, it's not much of a line.
On Tue, 2007-01-23 at 07:41 -0800, Spencer Graves wrote:> Consider the following: > > plot(0, 0, xlim=c(-10, 10), ylim=c(-50, 50)) > lines(c(0,0), (2*c(-pi, pi))^2) > > I see no line in this plot. > > R version 2.4.1 (2006-12-18) > i386-pc-mingw32 > > locale: > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United > States.1252;LC_MONETARY=English_United > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" > > My work around is the following: > > pi2.2 <- (2*pi)^2 > lines(c(0, 0), c(-pi2.2, pi2.2)) > > Why won't "lines(c(0,0), (2*c(-pi, pi))^2)" work for me? > Thanks, > Spencer GravesIn the first case, you are squaring 2*pi and 2*-pi, both resulting in the same positive number:> (2*c(-pi, pi))^2[1] 39.47842 39.47842 You are going from (0,39.47842) to (0,39.47842), hence no line. HTH, Marc Schwartz
you don't see the line b/c you're squaring both "pi" and "-pi" compare that with lines(c(0,0), c(-1,1)*(2*pi)^2) b On Jan 23, 2007, at 10:41 AM, Spencer Graves wrote:> Consider the following: > > plot(0, 0, xlim=c(-10, 10), ylim=c(-50, 50)) > lines(c(0,0), (2*c(-pi, pi))^2) > > I see no line in this plot. > > R version 2.4.1 (2006-12-18) > i386-pc-mingw32 > > locale: > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United > States.1252;LC_MONETARY=English_United > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" > "methods" > [7] "base" > > My work around is the following: > > pi2.2 <- (2*pi)^2 > lines(c(0, 0), c(-pi2.2, pi2.2)) > > Why won't "lines(c(0,0), (2*c(-pi, pi))^2)" work for me? > Thanks, > Spencer Graves > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
On Tue, 23 Jan 2007, Spencer Graves wrote:> Consider the following: > > plot(0, 0, xlim=c(-10, 10), ylim=c(-50, 50)) > lines(c(0,0), (2*c(-pi, pi))^2) > > I see no line in this plot.I do. You are drawing a line from a point to itself. Try lwd=5 and it will be more visible.> > R version 2.4.1 (2006-12-18) > i386-pc-mingw32 > > locale: > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United > States.1252;LC_MONETARY=English_United > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" > > My work around is the following: > > pi2.2 <- (2*pi)^2 > lines(c(0, 0), c(-pi2.2, pi2.2))What is (-1)^2?> Why won't "lines(c(0,0), (2*c(-pi, pi))^2)" work for me? > Thanks, > Spencer Graves > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Spencer Graves wrote:> Consider the following: > > plot(0, 0, xlim=c(-10, 10), ylim=c(-50, 50)) > lines(c(0,0), (2*c(-pi, pi))^2)Because squaring is done before multiplication - its higher priority. Hence you end up with (-2*pi)^2 and (2*pi)^2, which are the same, and your 'line' becomes a dot. How about: lines(c(0,0), (2*pi)^2*c(-1,1)) Barry