barmap: Interactive Bar plot and map

View source: R/barmap.R

barmapR Documentation

Interactive Bar plot and map

Description

The function barmap() draws a bar plot (vertical bar) of the given factor variable name.var and a map with sites of coordinates sf.obj.

Usage

barmap(sf.obj, name.var, type = c("count","percent"), names.arg = "", 
 criteria = NULL, carte = NULL, identify = NULL,
 cex.lab = 0.8, pch = 16, col = "lightblue3", xlab = "", ylab = "", 
 axes = FALSE, lablong = "", lablat = "")

Arguments

sf.obj

object of class sf

name.var

a character; attribute name or column number in attribute table

type

Character string indicating type of histogram to be drawn. "percent" and "count" give relative frequency and frequency histograms.

names.arg

a vector of level names of name.var

criteria

a vector of boolean of size the number os spatial units, which permit to represent preselected sites with a cross, using the tcltk window

carte

matrix with 2 columns for drawing spatial polygonal contours : x and y coordinates of the vertices of the polygon

identify

if not NULL, the name of the variable for identifying observations on the map

cex.lab

character size of label

pch

a vector of symbol which must be equal to the number of level else all sites are printed whith pch[1]

col

a vector of colors which must be equal to the number of level else all sites and all bars are printed with col[1]

xlab

a title for the graphic x-axis

ylab

a title for the graphic y-axis

axes

a boolean with TRUE for drawing axes on the map

lablong

name of the x-axis that will be printed on the map

lablat

name of the y-axis that will be printed on the map

Details

The selection of a bar on the bar plot results in the corresponding sites coloured on the map with the corresponding colour observed on the bar. Reversely, the selection of sites on the map by "points" or "polygon" results in the drawing of the sub-barplot in red.

Value

In the case where user click on save results button, a vector of integer is created as a global variable in last.select object. It corresponds to the number of spatial units selected just before leaving the Tk window.

Author(s)

Thomas-Agnan C., Aragon Y., Ruiz-Gazen A., Laurent T., Robidou L.

References

Thibault Laurent, Anne Ruiz-Gazen, Christine Thomas-Agnan (2012), GeoXp: An R Package for Exploratory Spatial Data Analysis. Journal of Statistical Software, 47(2), 1-23.

Roger S.Bivand, Edzer J.Pebesma, Virgilio Gomez-Rubio (2009), Applied Spatial Data Analysis with R, Springer.

See Also

histomap, histobarmap, scattermap, densitymap

Examples

######
# data eire
require(sf)
eire <- st_read(system.file("shapes/eire.shp", package="spData")[1])

# a basic usage ...
barmap(eire, "pale")

# ... with all options
barmap(eire, 3, type = "percent", col = c("pink", "orange"), 
  names.arg = c("not pale", "pale"), 
  criteria = NULL, identify = TRUE, cex.lab = 0.8, 
  xlab = "Are majority people are pale ?", ylab = "Percent", 
  axes = TRUE, lablong = "longitude", lablat = "latitude")

tibo31/GeoXp documentation built on April 8, 2023, 7:50 a.m.