View source: R/barplotCountryData.r
barplotCountryData | R Documentation |
Draw a barplot of country-level data, ranking the countries to allow easy
comparison.
One bar per country and to be able to read country names.
This is useful for comparing with maps created by
mapCountryData
and accepts many of the same arguments for
categorising and colouring.
barplotCountryData(
dF = "",
nameColumnToPlot = "",
nameCountryColumn = "NAME",
numPanels = 4,
scaleSameInPanels = FALSE,
main = nameColumnToPlot,
numCats = 5,
catMethod = "quantiles",
colourPalette = "heat",
addLegend = TRUE,
toPDF = FALSE,
outFile = "",
decreasing = TRUE,
na.last = TRUE,
cex = 0.7,
...
)
dF |
a dataframe containing at least one column with numeric data and one with country names or other labels |
nameColumnToPlot |
name of column containing the data you want to plot |
nameCountryColumn |
name of column containing country names (or other labels to be used in plot) |
numPanels |
the number of layout panels in the plot |
scaleSameInPanels |
whether to set the scale the same in each panel TRUE/FALSE, default=FALSE allowing more of the variability in the data to be viewed |
main |
title for the plot |
numCats |
number of categories to put the data in, may be modified if this number is incompatible with the catMethod chosen |
catMethod |
method for categorisation of data "pretty", "fixedWidth", "diverging", "logFixedWidth","quantiles","categorical", or a numeric vector defining breaks |
colourPalette |
a string describing the colour palette to use, choice of :
|
addLegend |
NOT YET WORKING whether to add a legend or not, TRUE/FALSE |
toPDF |
whether to output the plot to a pdf rather than the screen, TRUE/FALSE |
outFile |
output filename if toPDF=TRUE |
decreasing |
logical. Should the sort order be increasing or decreasing? |
na.last |
for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed. |
cex |
sizing of labels, default = 0.7 |
... |
other arguments to pass to barplot |
Finer control can be achieved by addMapLegend
.
invisibly returns a list containing the data and main options used
for the map, the list can be passed to addMapLegend
or
addMapLegendBoxes
along with additional options to allow
greater flexibility in legend creation.
will generate unhelpful errors in data categorisation if inappropriate options are chosen, e.g. with catMethod:Quantiles if numCats too high so that unique breaks cannot be defined.
andy south
classInt, RColorBrewer
#default uses popn data in the default map
barplotCountryData()
data("countryExData",envir=environment(),package="rworldmap")
barplotCountryData( countryExData
, nameColumnToPlot="BIODIVERSITY"
, nameCountryColumn = "Country"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.