if (FALSE) {
## Load the data
data(puechabonsp)
locs <- puechabonsp$relocs
map <- puechabonsp$map
## compute the home range of animals (e.g. using the minimum convex
## polygon)
pc <- mcp(locs[,"Name"])
## rasterize it
hr <- hr.rast(pc, map)
## Compute the number of relocation in each pixel of the map
cp <- count.points(locs[,"Name"], map)
## prepares the data for the kselect analysis
x <- prepksel(map, hr, cp)
tab <- x$tab
## Example of analysis with two variables: the slope and the elevation.
## Have a look at the use and availability of the two variables
## for the 4 animals
tab <- tab[,((names(tab) == "Slope")|(names(tab) == "Elevation"))]
tab <- scale(tab)
tmp <- split.data.frame(tab, x$factor)
wg <- split(x$weight, x$factor)
opar <- par(mfrow = n2mfrow(nlevels(x$factor)))
for (i in names(tmp))
s.distri(scale(tmp[[i]]), wg[[i]])
par(opar)
## We call a new graphic window
x11()
## A K-select analysis
acp <- dudi.pca(tab, scannf = FALSE, nf = 2)
kn <- kselect(acp, x$factor, x$weight,
scannf = FALSE, nf = 2)
# use of the generic function scatter
scatter(kn)
# Displays the first factorial plane
kplot(kn)
kplot(kn, cellipse = 0, cpoint = 0)
kplot(kn, addval = FALSE, cstar = 0)
# this factorial plane can be compared with
# the other graph to see the rotation proposed by
# the analysis
graphics.off()
# Displays the first factorial axis
hist(kn)
# Displays the second factorial axis
hist(kn, xax = 2)
# Summary of the analysis
plot(kn)
}
Run the code above in your browser using DataLab