[R] creating functions in R

Roger Bivand Roger.Bivand at nhh.no
Fri Mar 18 12:41:13 CET 2005


On Fri, 18 Mar 2005, Uwe Ligges wrote:

> Oarabile Ruth Molaodi wrote:
> 
> > I am trying to learn how to create my own function in R. I want to 
> > create a function that can plot the polygons/regions/map given the 
> > coordinates of each region. The function should be able to colour the 
> > poplygons according to the data supplied ,for examples the means or 
> > rates of disease at a region/polygon.
> 
> 
> You might want to take a look at package "maps".

Or others mentioned on http://www.R-project.org/Rgeo, for example, see how 
the DCluster package plots disease rates, or look at plot.polylist() in 
the maptools package. The maps package does depend on the user building a 
geographical database first, rather than taking an arbitrary ring of 
coordinates as a polygon. Colouring is a class interval problem, which has 
to be done separately anyway - see the examples on the help pages for the 
relevant functions (hint - findInterval() is good at setting the colour 
vector for the polygons).

Roger Bivand

> 
> Uwe Ligges
> 
> 
> > your advise will be highly appreciated.
> > 
> > Thanks in advance for your help.
> > 
> > Oarabile
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! 
> > http://www.R-project.org/posting-guide.html
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list