Learn R Programming

OutbreakTools (version 0.1-16)

plotGeo: Function to plot cases on a map

Description

Function to plot the geographic distribution of data in an '>obkData.

Usage

plotGeo(x, location=NULL, zoom='auto', source='google',
          colorBy=NULL, shapeBy=NULL, center=NULL, …)

Arguments

x

the main '>obkData object

location

the name of the columns containing location data; if a vector of length 2 is provided, these are expected to be longitudes and latitudes.

zoom

a numeric indicating the level of zooming; higher number gives smaller scale (higher zoom).

source

a character string indicating the internet source from which to download maps.

colorBy

the name of the attribute to use for coloring the symbols.

shapeBy

the name of the attribute to use for shaping the symbols.

center

individualID of individual to put at the center of the map. If left empty, method will focus on the center of all points

further arguments passed to geom_point.

Examples

Run this code
# NOT RUN {
## load the obkData of equine influenza outbreak
data(HorseFlu)
x <- HorseFlu

## plot the individuals on a map
plotGeo(x,location=c('lon','lat'),zoom=8)

## color by sex
plotGeo(x,location=c('lon','lat'),zoom=8,colorBy='sex')

## zoom in on the small cluster, by centering on individual '9'
plotGeo(x,location=c('lon','lat'),colorBy="sex",zoom=14,center='9',size=4,
  alpha=(.7))

plotGeo(x,location=c('lon','lat'),colorBy="yardID", shapeBy="sex", zoom=14,center='9',size=4,
  alpha=(.7))

## another example ##
## load obkData object containing data about a simulated outbreak
data(ToyOutbreak)

## plot the individuals on a map
plotGeo(ToyOutbreak,location=c('lon','lat'), zoom=8)
plotGeo(ToyOutbreak,location=c('lon','lat'), zoom=13, colorBy='Sex', size=3)

## color by age, zooming on the first case of the outbreak: indivudal 1
plotGeo(ToyOutbreak,location=c('lon','lat'), zoom=15,
        colorBy='Age', center='1', size=5)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab