[Rd] arrows: no vectors for "code" and "angle" parameters
Paul Johnson
pauljohn32 at gmail.com
Mon Jun 19 23:58:40 CEST 2017
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.
More information about the R-devel
mailing list