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

Paul Murrell paul at stat.auckland.ac.nz
Tue Jun 20 02:23:26 CEST 2017


Hi

I have added a warning (r-devel r72811).

I did this rather than allow vectors for length/angle/code because ...
- consistency with (implicit) description of arguments in help page
- backward compatibility (or at least no risk of not-backwards-incompatible)
- it was easier

Note that it is only the length/angle/code that are scalar, e.g., the 
graphical parameters ARE recycled ...

arrows(x0 = x0, y0 = y0, x1 = x1, y1 = y1,
        length = mylengths, code = mycodes, angle = myangle,
        col = 1:3, lwd=1:3, lty=1:3)

Thanks for the report and suggestion.

Paul

On 20/06/17 09:58, Paul Johnson wrote:
> 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
> 

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-devel mailing list