[R] conflict when passing an argument to a function within an other function
murdoch.duncan at gmail.com
Sun Nov 27 18:35:54 CET 2011
On 11-11-27 10:32 AM, Sylvain Antoniazza wrote:
> Dear all,
> I have a problem with this piece of code which I don't really see how to
> overcome and I think it might also be of more general interest:
> The idea is to use the map function from the maps package to draw a map of
> Europe. By default with the argument fill=T there is border to the
> polygones and I want them without border. Here is the start of the problems.
> The polygone function used in map function has a border argument that can
> deal with that issue, the problem is that this argument cannot be passed to
> map directly because map also has a border argument for another purpose (I
> tried with the density argument for polygone passed to map and here it is
> working (because map don't have a density argument itself)).
For problems like this you need to look at the source code. map() calls
polygon(), passing ... to it. So you want border in the ..., but since
border is an argument to map, it is already taken.
So make use of partial argument matching. Pass border to map, and bord
or borde to polygon:
The first one matches border, the second gets passed to polygon.
> Is there any way to pass a border argument to the polygone function within
> Thanks in advance for your help.
> Cheers, Sylvain.
> PS: for the moment I used a trick with the fg argument passed to par which
> allows to pass a colour for the border of the polygons.
More information about the R-help