Histogram, barplot and map

Share:

Description

The function histobarmap() draws a bar plot (vertical bar) of the given variable names.var[1], a histogram of the given variable names.var[2] and a map with sites of coordinates coordinates(sp.obj).

Usage

1
2
3
4
histobarmap(sp.obj, names.var, nbcol = 10, type = "count",
names.arg = "", names.attr=names(sp.obj), criteria=NULL, carte=NULL, identify=FALSE,
cex.lab=0.8, pch=16, col="lightblue3", xlab=c("barplot","histogram"), ylab=rep("count",2),
axes=FALSE, lablong="", lablat="")

Arguments

sp.obj

object of class extending Spatial-class

names.var

a vector of 2 characters; first character corresponds to the name of a factor and second character corresponds to a numeric value

nbcol

number of cells for histogram (10 by default)

type

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

names.arg

a vector of level names (for factor)

names.attr

names to use in panel (if different from the names of variable used in sp.obj)

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 FALSE, identify plotted objects (currently only working for points plots). Labels for identification are the row.names of the attribute table row.names(as.data.frame(sp.obj)).

cex.lab

character size of label

pch

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

col

a vector of colors which must be equal to the number of group else all sites and all box are printed in col[1]

xlab

a vector of names for x-title of the barplot and histogram

ylab

a vector of names for y-title of the barplot and histogram

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

Each site is associated to a factor of names.var[1] and to a value of names.var[2]. There is interactivity between the three windows created: the sites selected by a bar on the bar plot or on the histogram are represented on the map in red and the value and factor of sites selected on the map are represented in red on the bar plot and on the histogram.

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

dblehistomap, histobarmap, scattermap, dbledensitymap

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
###
# Data Colombus
require("maptools")
example(columbus)

# an example of use
histobarmap(columbus,c("CP","HOVAL"),nbcol=8, type="percent",
names.arg=c("A","B"), xlab=c("CP","Hoval"), ylab=rep("percent",2))

######
# data eire
eire <- readShapePoly(system.file("etc/shapes/eire.shp", package="spdep")[1],
ID="names", proj4string=CRS("+proj=utm +zone=30 +units=km"))

# example of use
histobarmap(eire, c("pale","A"),names.arg=c("Ouside Pale","Pale"),
xlab=c("Appartenance to the region of Pale","Average number of people with blood A"),
col=colors()[101:102],identify=TRUE)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.