Skip to content

creating functions in R

3 messages · Oarabile Ruth Molaodi, Uwe Ligges, Roger Bivand

#
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.

your advise will be highly appreciated.

Thanks in advance for your help.

Oarabile
#
Oarabile Ruth Molaodi wrote:

            
You might want to take a look at package "maps".

Uwe Ligges
#
On Fri, 18 Mar 2005, Uwe Ligges wrote:

            
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