From pauljohn32 at gmail.com  Mon Jun 19 23:58:40 2017
From: pauljohn32 at gmail.com (Paul Johnson)
Date: Mon, 19 Jun 2017 16:58:40 -0500
Subject: [Rd] arrows: no vectors for "code" and "angle" parameters
Message-ID: <CAErODj99M1+-o_v39PKKWsPh=_TRp8DkDtYXds=8sHZSTTketQ@mail.gmail.com>

I was teaching new R users to make some fun graphs. I had some arrows examples
worked up we came across a problem.  The arrows function ignores 2nd
and following elements of vectors given as code an angle.

Would you please consider 1) allowing vectors for code and angle, or
2) returning an error or warning when user mistakenly supplies a
vector for those parameters?  When code like this is wrapped into an
Sweaved document--we I don't see the graph on the screen--this error
is difficult to catch while proofreading.

Example:

x0 <- c(-1, -4, 4.5)
y0 <- c(-1, -4, -8)
x1 <- c(2, -2, -3)
y1 <- c(4, 4, 18)
mylengths <- c(0.2, 0.3, 0.15)
mycodes <- c(3, 2, 1)
myangle <- c(10, 60, 80)

plot(x = c(-5, 5), y = c(-10, 20),
     type = "n", xlab = "", ylab = "")

arrows(x0 = x0, y0 = y0, x1 = x1, y1 = y1,
       length = mylengths, code = mycodes, angle = myangle)

I found a workaround, but this is more difficult to explain to beginners...

plot(x = c(-5, 5), y = c(-10, 20),
     type = "n", xlab = "", ylab = "")

mapply(arrows, x0 = x0, y0 = y0, x1 = x1, y1 = y1,
       length = mylengths, angle = myangle, code = mycodes)

pj

-- 
Paul E. Johnson   http://pj.freefaculty.org
Director, Center for Research Methods and Data Analysis http://crmda.ku.edu

To write to me directly, please address me at pauljohn at ku.edu.



[Rd] arrows: no vectors for "code" and "angle" parameters
Paul Johnson