R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("adehabitat-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('adehabitat') Loading required package: ade4 > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "NNCH" > > ### * NNCH > > flush(stderr()); flush(stdout()) > > ### Name: NNCH > ### Title: Nearest Neighbor Convex hull > ### Aliases: NNCH print.NNCH plot.NNCH NNCH.area plot.NNCHver neighNNCH > ### plot.ngNNCH getverticesNNCH NNCH.rast > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D > ##D ## Can also be used to analyse a point pattern > ##D ## For example, locations of chamois in > ##D ## the Chartreuse mountains (French Alps) > ##D > ##D data(chamois) > ##D xy <- chamois$locs > ##D > ##D ## choice of the number of neighbors > ##D ## Warning: this command can be very long (more than two minutes) > ##D u <- neighNNCH(xy, rangek = 5:30) > ##D plot(u) > ##D > ##D ## 13 and 20 neighbours seem to be a good choice > ##D ## Estimates the home range levels > ##D (aa <- NNCH(xy, k = 13)) > ##D plot(aa) > ##D > ##D ## plot of the home-range size > ##D plot(NNCH.area(aa)) > ##D > ##D ## gets the home range contour > ##D cont <- getverticesNNCH(aa) > ##D plot(cont) > ##D > ##D ## rasterizes these contours > ##D sl <- getkasc(chamois$map, "Slope") > ##D mm <- NNCH.rast(cont, sl) > ##D image(mm) > ##D > ##D ## Note that two different sets of polygons can include > ##D ## the same percentage of relocation > ##D aa[[1]]$area[97:105,] > ##D > ##D ## For example, the same percentage of relocations is > ##D ## included within the limits of the two home ranges > ##D ## (91.92 percent of the localisations) > ##D opar <- par(mfrow=c(1,2)) > ##D plot(aa[[1]]$polygons[[103]], > ##D poly.args = list(lwd = 2)) > ##D points(xy, pch = 16, cex = 0.5) > ##D > ##D plot(aa[[1]]$polygons[[98]], > ##D poly.args = list(lwd = 2)) > ##D points(xy, pch=16, cex = 0.5) > ##D par(opar) > ##D ## only the left-hand plot is considered as an > ##D ## home range estimation (the larger one) > ##D > ## End(Not run) > > > > > cleanEx(); ..nameEx <- "angles" > > ### * angles > > flush(stderr()); flush(stdout()) > > ### Name: angles > ### Title: Compute Turning Angles > ### Aliases: angles > ### Keywords: spatial > > ### ** Examples > > ## loads an object of class "traj" > data(puechcirc) > puechcirc ******** Data frame of class traj ********* Animal CH93 : 2 circuits (118 relocations) Animal JE93 : 2 circuits (86 relocations) Variables measured for each relocation: [1] id x y date burst > > ## Gets a part of the trajectory of the wild boar named > ## CH93 and draws it > ## Also displays the turning angles > toto <- puechcirc[2:5,] > plot(toto$x, toto$y, asp = 1, ylim = c(3158300, 3158550), + pch = 16, + main = "Turning angles between\nthree consecutive moves", + xlab="X", ylab="Y") > lines(toto$x, toto$y) > lines(c(toto$x[2], 700217.6), + c(toto$y[2], 3158310), lty=2) > lines(c(toto$x[3],700289), + c(toto$y[3],3158546), lty=2) > ang1x <- c(700234.8, 700231.9, 700231, 700233.7, 700238.8, 700243.2) > ang1y <- c(3158332, 3158336, 3158341, 3158347, 3158350, 3158350) > ang2x <- c(700283.3, 700278.8, 700275.4, 700272.4, 700271.2, 700271.6, + 700274.7) > ang2y <- c(3158522, 3158522, 3158520, 3158517, 3158514, 3158508, 3158504) > lines(ang1x, ang1y) > lines(ang2x, ang2y) > text(700216.1, 3158349, expression(theta[1]), cex=2) > text(700247.7, 3158531, expression(theta[2]), cex=2) > text(c(700301, 700231), c(3158399, 3158487), + c("Beginning", "End"), pos=4) > > > ## Computation of the turning angles with real data > ## on wild boars > plot(puechcirc) > ang <- angles(puechcirc) > > ## The angles are in the column Angles: > ang[1:4,] id x y date burst angles 1 CH93 700291 3158404 1993-08-24 17:20:00 CH930824 3.051356 2 CH93 700241 3158340 1993-08-24 17:30:00 CH930824 -2.706886 3 CH93 700281 3158512 1993-08-24 17:40:00 CH930824 2.690675 4 CH93 700260 3158486 1993-08-24 17:50:00 CH930824 -3.105680 > > > > > cleanEx(); ..nameEx <- "area2dxf" > > ### * area2dxf > > flush(stderr()); flush(stdout()) > > ### Name: area2dxf > ### Title: Exportation of Areas > ### Aliases: area2dxf > ### Keywords: hplot > > ### ** Examples > > > ## Not run: > ##D ## Loads the dataset elec88 from the package ade4 > ##D data(elec88) > ##D ar <- as.area(elec88$area) > ##D area.plot(ar, lab = elec88$lab, clab = 0.75) > ##D > ##D ## exportation of the departments toward a dxf file > ##D area2dxf(ar, file = "Dept", lay = elec88$lab) > ##D > ##D ## Removes the file > ##D file.remove("Dept.dxf") > ## End(Not run) > > > > > > cleanEx(); ..nameEx <- "as.area" > > ### * as.area > > flush(stderr()); flush(stdout()) > > ### Name: as.area > ### Title: Objects of Class "area" > ### Aliases: as.area area > ### Keywords: spatial > > ### ** Examples > > data(elec88) > ar <- as.area(elec88$area) > plot(ar) > > > > cleanEx(); ..nameEx <- "as.kasc" > > ### * as.kasc > > flush(stderr()); flush(stdout()) > > ### Name: as.kasc > ### Title: Working with Several Raster Maps > ### Aliases: as.kasc kasc getkasc image.kasc print.kasc > ### Keywords: programming hplot > > ### ** Examples > > > data(puechabon) > > ## kasc is a list of class kasc > (kasc <- puechabon$kasc) Raster map of class "kasc": Cell size: 100 Number of rows: 121 Number of columns: 111 Variables measured: 1. Elevation: numeric 2. Aspect: factor 3. Slope: numeric 4. Herbaceous: numeric > > ## Stores two elements of the kasc in objects > ## of class asc > (asp <- getkasc(kasc, "Aspect")) Raster map of class "asc": Cell size: 100 Number of rows: 121 Number of columns: 111 Type: factor > (sl <- getkasc(kasc, "Slope")) Raster map of class "asc": Cell size: 100 Number of rows: 121 Number of columns: 111 Type: numeric > > ## Displays the slopes on the area (numeric) > image(sl, main = "Aspect", xlab = "Lambert X", ylab = "Lambert Y") > > ## Aspect is a factor: > ## cl is the list of color associated with the levels > ## of asp > cl <- colasc(asp, NorthEast = "blue", SouthEast = "red", + SouthWest = "orange", NorthWest = "green") > image(asp, clfac = cl, main = "Aspect", xlab = "Lambert X", + ylab = "Lambert Y") > legend(706500, 3162000, legend=levels(asp), fill=cl, cex=0.7) > > > ## Creation of a new kasc with elevation > ## and slopes > cuicui <- as.kasc(list(Slope = sl, Aspect = asp)) > > ## Displays the kasc object > ## with random colors for aspect and grey levels for slopes > image(cuicui) > > ## with cm.colors for slopes (numeric) > ## and cl for aspect (factor) > image(cuicui, col = cm.colors(256), clfac = list(Aspect = cl)) > > ## plots only slope > image(cuicui, "Slope", main="Slope") > ## similar to > image(cuicui, 1, main = "Slope") > > > > > cleanEx(); ..nameEx <- "as.sahrlocs" > > ### * as.sahrlocs > > flush(stderr()); flush(stdout()) > > ### Name: as.sahrlocs > ### Title: Exploratory Analysis of Habitat Selection > ### Aliases: as.sahrlocs getsahrlocs print.sahrlocs > ### Keywords: spatial multivariate > > ### ** Examples > > data(puechabon) > kasc <- puechabon$kasc > locs <- puechabon$locs > > ## Computes the home ranges of the animals... > cp <- mcp(locs[,4:5], locs[,1]) > > ## ... and converts it to raster > cprast <- hr.rast(cp, kasc) > locrast <- count.points.id(locs[,4:5], locs[,1], kasc) > > ## Creation of the sahrlocs object > (sahr <- as.sahrlocs(locrast, cprast, kasc)) ************** Object of type sahrlocs ************** The area of interest is a 121 * 111 raster matrix 4 animals are available : [1] "Brock" "Calou" "Chou" "Jean" the following variables are available for the study area: [1] "Elevation" "Aspect" "Slope" "Herbaceous" no variables have been measured on the animals > > ## adds information on the monitored animals > age <- factor(tapply(locs[,2], locs[,1], mean)) > sex <- factor(tapply(locs[,3], locs[,1], mean)) > info <- as.data.frame(cbind(sex, age)) > (sahr <- as.sahrlocs(locrast, cprast, kasc, info)) ************** Object of type sahrlocs ************** The area of interest is a 121 * 111 raster matrix 4 animals are available : [1] "Brock" "Calou" "Chou" "Jean" the following variables are available for the study area: [1] "Elevation" "Aspect" "Slope" "Herbaceous" the following variables are available for each monitored animal: [1] "sex" "age" > > ## Gets the "study area" component of the object > toto <- getsahrlocs(sahr) > image(toto) > > > > cleanEx(); ..nameEx <- "as.traj" > > ### * as.traj > > flush(stderr()); flush(stdout()) > > ### Name: as.traj > ### Title: Working with Trajectories in 2D Space > ### Aliases: as.traj traj print.traj summary.traj plot.traj getburst > ### traj2df df2traj > ### Keywords: spatial > > ### ** Examples > > > data(puechabon) > locs <- puechabon$locs > locs[1:4,] Name Age Sex X Y Date 1 Brock 2 1 699889 3161559 930701 2 Brock 2 1 700046 3161541 930703 3 Brock 2 1 698840 3161033 930706 4 Brock 2 1 699809 3161496 930707 > > ### Conversion of the date to the format POSIX > da <- as.character(locs$Date) > da <- as.POSIXct(strptime(as.character(locs$Date), + "%y%m%d")) > > ### Creation of the object of class "traj" > (tr <- as.traj(id = locs$Name, xy = locs[,c("X", "Y")], + date = da)) ******** Data frame of class traj ********* Animal Brock : 1 circuits (30 relocations) Animal Calou : 1 circuits (19 relocations) Animal Chou : 1 circuits (40 relocations) Animal Jean : 1 circuits (30 relocations) Variables measured for each relocation: [1] id x y date burst > summary(tr) Animal Brock : 1 circuits. Number of relocations per circuit: Brock 30 Animal Calou : 1 circuits. Number of relocations per circuit: Calou 19 Animal Chou : 1 circuits. Number of relocations per circuit: Chou 40 Animal Jean : 1 circuits. Number of relocations per circuit: Jean 30 > plot(tr) > > ### Displays on maps of the study area > k <- puechabon$kasc > ele <- getkasc(k, "Elevation") > plot(tr, asc = ele) > > ### Case with several burst per animal > data(puechcirc) > plot(puechcirc, asc = ele) > plot(puechcirc, asc = ele, perani = FALSE) > > > > > cleanEx(); ..nameEx <- "asc2im" > > ### * asc2im > > flush(stderr()); flush(stdout()) > > ### Name: asc2im > ### Title: Conversion of Maps of Class 'asc' and 'im' (Package spatstat) > ### Aliases: asc2im im2asc > ### Keywords: spatial > > ### ** Examples > > if (require(spatstat)) { + + ####################### + ### Conversion asc -> im + + data(puechabon) + el <- getkasc(puechabon$kasc, "Elevation") + image(el, main = "An object of class \"asc\"") + elim <- asc2im(el) + image(elim, main = "An object of class \"im\"") + + ####################### + ### Conversion im -> asc + u <- matrix(rnorm(10000), 100, 100) + haha <- im(u) + image(haha, main = "class im") + hihi <- im2asc(haha) + image(hihi, main = "class asc") + + } Loading required package: spatstat Loading required package: mgcv This is mgcv 1.3-1 Loading required package: sm Library `sm', version 2; Copyright (C) 1997, 2000 A.W.Bowman & A.Azzalini type help(sm) for summary information spatstat 1.6-9 Type "demo(spatstat)" for a demonstration See the Introduction and Quick Reference in /CRANPkg/lib/spatstat/doc Attaching package: 'spatstat' The following object(s) are masked from package:adehabitat : rotxy > > > > cleanEx(); ..nameEx <- "ascgen" > > ### * ascgen > > flush(stderr()); flush(stdout()) > > ### Name: ascgen > ### Title: Creation of Raster Maps > ### Aliases: ascgen > ### Keywords: spatial > > ### ** Examples > > data(puechabon) > lo <- puechabon$locs[,c("X","Y")] > plot(lo, asp = 1, pch = 16) > > ## lo contains the relocations of wild boars > rast <- ascgen(lo, cellsize = 100) > image(rast) > > ## Alternatively, one can specify the size of the square raster map > rast <- ascgen(lo, nrcol = 10) > rast Raster map of class "asc": Cell size: 425.5556 Number of rows: 10 Number of columns: 10 Type: numeric > image(rast) > > ## can be used for further analyses > ## (e.g. correspondence analyses) > locs <- puechabon$locs[, c("Name", "X", "Y")] > o <- count.points.id(locs[,2:3], locs[,1], rast) > image(o) > > > > cleanEx(); ..nameEx <- "biv.test" > > ### * biv.test > > flush(stderr()); flush(stdout()) > > ### Name: biv.test > ### Title: Bivariate Test > ### Aliases: biv.plot biv.test > ### Keywords: multivariate > > ### ** Examples > > > ## Not run: > ##D x = rnorm(1000,2) > ##D y = 2*x+rnorm(1000,2) > ##D dfxy = data.frame(x, y) > ##D > ##D biv.plot(dfxy) > ##D biv.plot(dfxy, points=F, col="lightblue", br=20) > ##D > ##D p = c(3, 4) > ##D biv.test(dfxy, p) > ##D biv.test(dfxy, p, points=F, Pcol="darkred", col="lightblue", br=20) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "buffer" > > ### * buffer > > flush(stderr()); flush(stdout()) > > ### Name: buffer > ### Title: Compute Buffers > ### Aliases: buffer buffer.ani buffer.line > ### Keywords: spatial > > ### ** Examples > > data(puechabon) > > # locs is the data frame containing the > # relocations of wild boars monitored by radio-tracking > locs <- puechabon$locs > > # sa is the "kasc" object of maps of the study area > sa <- puechabon$kasc > > # Buffer of 500 m around all relocations > bu <- buffer(locs[,4:5], sa, 500) > image(bu) > > # displays all the pixels of the study area within 500 m > # of a relocation of each monitored wild boar > buani <- buffer.ani(locs[,4:5], locs[,1], sa, 500) > image(buani) > > ## buffer around a trajectory > data(puechcirc) > uu <- getburst(puechcirc, burst = "CH930824") > w <- ascgen(uu[,c("x","y")], nrcol = 100) > out <- buffer.line(uu[,c("x","y")], w, 100) > image(out) > plot(uu, asc = out) > > > > > cleanEx(); ..nameEx <- "colasc" > > ### * colasc > > flush(stderr()); flush(stdout()) > > ### Name: colasc > ### Title: Creates a Vector of Colors for a Raster Map of Type 'factor' > ### Aliases: colasc > ### Keywords: programming > > ### ** Examples > > data(puechabon) > > ## gets the aspect in an asc object > asp <- getkasc(puechabon$kasc, "Aspect") > > ## creates the vector of colors > cl <- colasc(asp, NorthEast = "blue", SouthEast = "red", + SouthWest = "orange", NorthWest = "green") > > ## graphical display > image(asp, clfac = cl, main = "Aspect", xlab = "Lambert X", + ylab = "Lambert Y") > legend(706500, 3162000, legend=levels(asp), fill = cl, cex = 0.7) > > > > > cleanEx(); ..nameEx <- "compana" > > ### * compana > > flush(stderr()); flush(stdout()) > > ### Name: compana > ### Title: Compositional Analysis of Habitat Use > ### Aliases: compana print.compana > ### Keywords: math > > ### ** Examples > > > ## The examples presented here > ## are the same as those presented in > ## the paper of Aebischer et al. (1993) > > ############################# > ## Pheasant dataset: first > ## example in Aebischer et al. > > data(pheasant) > > ## Second order habitat selection > ## Selection of home range within the > ## study area (example of parametric test) > pheana2 <- compana(pheasant$mcp, pheasant$studyarea, + test = "parametric") > pheana2 ************ Compositional analysis of habitat use *************** The analysis was carried out with 13 animals and 5 habitat types 1. Test of the habitat selection: parametric test Lambda df P 8.491656e-02 4.000000e+00 1.860604e-06 2. Ranking of habitats (profile): habitat Scrub Broadleaf Grassland Coniferous Crop Scrub ------------------ Broadleaf ------------------ Grassland ----------------------- Coniferous ----------------------- Crop ------ > > ## The ranking matrix: > print(pheana2$rm, quote = FALSE) Scrub Broadleaf Coniferous Grassland Crop Scrub 0 + +++ +++ +++ Broadleaf - 0 +++ +++ +++ Coniferous --- --- 0 - +++ Grassland --- --- + 0 +++ Crop --- --- --- --- 0 > > ## Third order habitat selection > ## (relocation within home range) > ## We remove the first pheasant of the analysis > ## (as in the paper of Aebischer et al.) > ## before the analysis > pheana3 <- compana(pheasant$locs[-1,], pheasant$mcp[-1,c(1,2,4)]) > pheana3 ************ Compositional analysis of habitat use *************** The analysis was carried out with 12 animals and 3 habitat types 1. Test of the habitat selection: randomisation test Lambda P 0.3655733 0.0060000 2. Ranking of habitats (profile): habitat Broadleaf Scrub Grassland Broadleaf ------------------ Scrub ------------------ Grassland ----------- > > ## The ranking matrix: > print(pheana3$rm, quote = FALSE) Scrub Broadleaf Grassland Scrub 0 - +++ Broadleaf + 0 +++ Grassland --- --- 0 > > > ############################# > ## Squirrel data set: second > ## example in Aebischer et al. > > data(squirrel) > > ## Second order habitat selection > ## Selection of home range within the > ## study area > squiana2 <- compana(squirrel$mcp, squirrel$studyarea) > squiana2 ************ Compositional analysis of habitat use *************** The analysis was carried out with 17 animals and 5 habitat types 1. Test of the habitat selection: randomisation test Lambda P 0.06808452 0.00200000 2. Ranking of habitats (profile): habitat Larch Mature Young Open Thuja Larch ---------------------- Mature ---------------------- Young ---------------------------- Open ------------- Thuja ------- > > ## The ranking matrix: > print(squiana2$rm, quote = FALSE) Young Thuja Larch Mature Open Young 0 +++ - - + Thuja --- 0 --- --- --- Larch + +++ 0 + +++ Mature + +++ - 0 +++ Open - +++ --- --- 0 > > ## Third order habitat selection > ## (relocation within home range) > ## We remove the second column > ## (as in the paper of Aebischer et al.) > squiana3 <- compana(squirrel$locs[,-2], squirrel$mcp[,-2]) > squiana3 ************ Compositional analysis of habitat use *************** The analysis was carried out with 17 animals and 4 habitat types 1. Test of the habitat selection: randomisation test Lambda P 0.3445276 0.0080000 2. Ranking of habitats (profile): habitat Mature Open Young Larch Mature -------------- Open ---------------------------- Young -------------------- Larch -------------------- > > ## The ranking matrix: > print(squiana3$rm, quote = FALSE) Young Larch Mature Open Young 0 + --- - Larch - 0 --- - Mature +++ +++ 0 + Open + + - 0 > > > > > cleanEx(); ..nameEx <- "convnum" > > ### * convnum > > flush(stderr()); flush(stdout()) > > ### Name: convnum > ### Title: Conversion from Factor to Numeric for Raster Map > ### Aliases: convnum > ### Keywords: manip > > ### ** Examples > > > ## loads the data > data(puechabon) > kasc <- puechabon$kasc > image(kasc) > > ## scales all the variables > toto <- convnum(kasc) > image(toto$kasc) > > ## the Aspect has four levels: > ## four variables have been defined. > toto$weight Elevation Aspec.NorthEast Aspec.SouthEast Aspec.SouthWest Aspec.NorthWest 1.0000000 0.1226307 0.3434574 0.2881937 0.2457182 Slope Herbaceous 1.0000000 1.0000000 > > ## The sum of the weights given to each > ## level of aspect is equal to: > toto$weight[2:5] Aspec.NorthEast Aspec.SouthEast Aspec.SouthWest Aspec.NorthWest 0.1226307 0.3434574 0.2881937 0.2457182 > sum(toto$weight[2:5]) [1] 1 > > ## The same weight is therefore given to the factor variable Aspect and > ## to any continuous variable, e.g. the elevation. > > > > > cleanEx(); ..nameEx <- "count.points.id" > > ### * count.points.id > > flush(stderr()); flush(stdout()) > > ### Name: count.points.id > ### Title: Number of Points in Each Pixel of a Raster Map > ### Aliases: count.points.id count.points > ### Keywords: spatial > > ### ** Examples > > data(puechabon) > kasc <- puechabon$kasc > locs <- puechabon$locs > > ## Counts the number of relocations of each wild boar > ## per pixel of the raster map > (nlocrast <- count.points.id(locs[,4:5], locs[,1], kasc)) Raster map of class "kasc": Cell size: 100 Number of rows: 121 Number of columns: 111 Variables measured: 1. Brock: numeric 2. Calou: numeric 3. Chou: numeric 4. Jean: numeric > image(nlocrast) > > ## Counts the number of all relocations > ## per pixel of the raster map > (nlocrast <- count.points(locs[,c("X","Y")], kasc)) Raster map of class "asc": Cell size: 100 Number of rows: 121 Number of columns: 111 Type: numeric > image(nlocrast) > > > > > cleanEx(); ..nameEx <- "distfacmap" > > ### * distfacmap > > flush(stderr()); flush(stdout()) > > ### Name: distfacmap > ### Title: Compute distances to the different levels of a factor map > ### Aliases: distfacmap > ### Keywords: spatial > > ### ** Examples > > ## Not run: > ##D data(puechabon) > ##D asp <- getkasc(puechabon$kasc, "Aspect") > ##D image(asp) > ##D sor <- distfacmap(asp) > ##D image(sor) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "domain" > > ### * domain > > flush(stderr()); flush(stdout()) > > ### Name: domain > ### Title: Estimation of the Potential Distribution of a Species > ### Aliases: domain > ### Keywords: spatial multivariate > > ### ** Examples > > > ## Preparation of the data > data(puechabon) > kasc <- puechabon$kasc > kasc$Aspect <- NULL > pts <- puechabon$locs[puechabon$locs$Name == "Brock", 4:5] > > ## View of the data > elevation <- getkasc(kasc, "Elevation") > image(elevation) > points(pts, col = "red", pch = 16) > > ## Estimation of habitat suitability map > hsm <- domain(kasc, pts) > image(hsm, col = grey((1:256)/256)) > contour(hsm, add = TRUE) > ## Lighter areas are the most preferred areas > > ## Potential distribution > hsm <- domain(kasc, pts, type = "potential") > image(elevation, main = "Habitat suitability map") > image(hsm, add = TRUE, col = "orange") > points(pts, col = "red", pch = 16) > > > > > cleanEx(); ..nameEx <- "enfa" > > ### * enfa > > flush(stderr()); flush(stdout()) > > ### Name: enfa > ### Title: Ecological-Niche Factor Analysis > ### Aliases: enfa hist.enfa print.enfa data2enfa print.dataenfa > ### Keywords: multivariate > > ### ** Examples > > ## Not run: > ##D data(lynxjura) > ##D > ##D map <- lynxjura$map > ##D > ##D ## We keep only "wild" indices. > ##D tmp <- lynxjura$locs[,4]!="D" > ##D locs <- lynxjura$locs[tmp, c("X","Y")] > ##D hist(map, type = "l") > ##D ## The variable artif is far from symetric > ##D > ##D ## We perform a square root transformation > ##D ## of this variable > ##D ## We therefore normalize the variable 'artif' > ##D map[,4] <- sqrt(map[,4]) > ##D hist(map, type = "l") > ##D > ##D ## We prepare the data for the ENFA > ##D (dataenfa1 <- data2enfa(map, locs[tmp, c("X","Y")])) > ##D > ##D ## We then perform the ENFA > ##D (enfa1 <- enfa(dataenfa1$tab, dataenfa1$pr, > ##D scannf = FALSE)) > ##D hist(enfa1) > ##D hist(enfa1, scores = FALSE, type = "l") > ##D > ##D ## randomization test and scatterplot > ##D (renfa <- randtest(enfa1)) > ##D plot(renfa) > ##D scatter(enfa1) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "getXYcoords" > > ### * getXYcoords > > flush(stderr()); flush(stdout()) > > ### Name: getXYcoords > ### Title: Computes the X and Y Coordinates of the Pixels of a Raster Map > ### Aliases: getXYcoords > ### Keywords: programming > > ### ** Examples > > data(puechabon) > (elev <- getkasc(puechabon$kasc, "Elevation")) Raster map of class "asc": Cell size: 100 Number of rows: 121 Number of columns: 111 Type: numeric > (coords <- getXYcoords(elev)) $x [1] 697000 697100 697200 697300 697400 697500 697600 697700 697800 697900 [11] 698000 698100 698200 698300 698400 698500 698600 698700 698800 698900 [21] 699000 699100 699200 699300 699400 699500 699600 699700 699800 699900 [31] 700000 700100 700200 700300 700400 700500 700600 700700 700800 700900 [41] 701000 701100 701200 701300 701400 701500 701600 701700 701800 701900 [51] 702000 702100 702200 702300 702400 702500 702600 702700 702800 702900 [61] 703000 703100 703200 703300 703400 703500 703600 703700 703800 703900 [71] 704000 704100 704200 704300 704400 704500 704600 704700 704800 704900 [81] 705000 705100 705200 705300 705400 705500 705600 705700 705800 705900 [91] 706000 706100 706200 706300 706400 706500 706600 706700 706800 706900 [101] 707000 707100 707200 707300 707400 707500 707600 707700 707800 707900 [111] 708000 $y [1] 3155000 3155100 3155200 3155300 3155400 3155500 3155600 3155700 3155800 [10] 3155900 3156000 3156100 3156200 3156300 3156400 3156500 3156600 3156700 [19] 3156800 3156900 3157000 3157100 3157200 3157300 3157400 3157500 3157600 [28] 3157700 3157800 3157900 3158000 3158100 3158200 3158300 3158400 3158500 [37] 3158600 3158700 3158800 3158900 3159000 3159100 3159200 3159300 3159400 [46] 3159500 3159600 3159700 3159800 3159900 3160000 3160100 3160200 3160300 [55] 3160400 3160500 3160600 3160700 3160800 3160900 3161000 3161100 3161200 [64] 3161300 3161400 3161500 3161600 3161700 3161800 3161900 3162000 3162100 [73] 3162200 3162300 3162400 3162500 3162600 3162700 3162800 3162900 3163000 [82] 3163100 3163200 3163300 3163400 3163500 3163600 3163700 3163800 3163900 [91] 3164000 3164100 3164200 3164300 3164400 3164500 3164600 3164700 3164800 [100] 3164900 3165000 3165100 3165200 3165300 3165400 3165500 3165600 3165700 [109] 3165800 3165900 3166000 3166100 3166200 3166300 3166400 3166500 3166600 [118] 3166700 3166800 3166900 3167000 > nrow(elev) == length(coords$x) [1] TRUE > ncol(elev) == length(coords$y) [1] TRUE > > > > cleanEx(); ..nameEx <- "getascattr" > > ### * getascattr > > flush(stderr()); flush(stdout()) > > ### Name: getascattr > ### Title: Copy the Attributes of an Object of Class 'asc' or 'kasc' to > ### another Object > ### Aliases: getascattr getkascattr > ### Keywords: programming > > ### ** Examples > > data(puechabon) > > ## my.map is a map of elevation > my.map <- getkasc(puechabon$kasc, "Elevation") > sl <- getkasc(puechabon$kasc, "Slope") > attributes(sl) <- NULL > sl <- matrix(sl, ncol = ncol(my.map)) > > ## sl is a matrix with the same size as my.map > toto <- getascattr(my.map, sl) > image(toto) > > ## same rationale with aspect > asp <- getkasc(puechabon$kasc, "Aspect") > le <- levels(asp) > attributes(asp) <- NULL > asp <- matrix(asp, ncol = ncol(my.map)) > > ## asp is now a matrix with the same size as my.map > tutu <- getascattr(my.map, asp, typ = "factor", lev = le) > cl <- colasc(tutu, NorthEast = "blue", SouthEast = "red", + SouthWest = "orange", NorthWest = "green") > image(tutu, clfac = cl) > > > > > cleanEx(); ..nameEx <- "getcontour" > > ### * getcontour > > flush(stderr()); flush(stdout()) > > ### Name: getcontour > ### Title: Computes the Contour Polygon of a Raster Object > ### Aliases: getcontour > ### Keywords: programming hplot > > ### ** Examples > > > data(puechabon) > kasc <- puechabon$kasc > > ######################################### > ## Example with one object: > ## Gets the first map of the "kasc" object > ## Map of the elevation > elev <- getkasc(kasc, "Elevation") > image(elev) > > ## Get the contour polygon > cpol <- getcontour(elev) > > ## Draw the polygon > i <- cpol[,2:3] > polygon(i, col = "green", lwd = 2) > > ######################################### > ## Example with two objects: > ## home ranges of wild boar > > hr <- getsahrlocs(puechabon$sahr, "hr") > u <- getkasc(hr, "Jean") > image(u) > > ## Get the contour polygons > p <- getcontour(u) > plot(p, lwd = 2) > > > > > cleanEx(); ..nameEx <- "hist.kasc" > > ### * hist.kasc > > flush(stderr()); flush(stdout()) > > ### Name: hist.kasc > ### Title: Histograms of Mapped Variables > ### Aliases: hist.kasc > ### Keywords: hplot > > ### ** Examples > > > ## Example with factors and numeric variables > data(puechabon) > hist(puechabon$kasc) > > ## Removing the factor Aspect, and smoothing gives : > hist(puechabon$kasc[,-2], type = "l") > > > > > cleanEx(); ..nameEx <- "histniche" > > ### * histniche > > flush(stderr()); flush(stdout()) > > ### Name: histniche > ### Title: Histograms of the Ecological Niche > ### Aliases: histniche > ### Keywords: multivariate > > ### ** Examples > > ## Not run: > ##D ## Example with factors and numeric variables > ##D data(puechabon) > ##D histniche(puechabon$kasc, puechabon$locs[, c("X", "Y")]) > ##D > ##D ## Aspect is a factor, then it's not possible to use > ##D ## kernel density estimates for it : > ##D histniche(puechabon$kasc, puechabon$locs[, c("X", "Y")], type = "l") > ## End(Not run) > > > > cleanEx(); ..nameEx <- "hr.rast" > > ### * hr.rast > > flush(stderr()); flush(stdout()) > > ### Name: hr.rast > ### Title: Rasterisation of Objects of Class 'area' > ### Aliases: hr.rast > ### Keywords: spatial > > ### ** Examples > > data(puechabon) > kasc <- puechabon$kasc > locs <- puechabon$locs > > ## Computes the home range of the animals > cp <- mcp(locs[,4:5], locs[,1]) > area.plot(cp) > > ## Converts the home range to raster > cprast <- hr.rast(cp, kasc) > image(cprast) > > > > cleanEx(); ..nameEx <- "image.asc" > > ### * image.asc > > flush(stderr()); flush(stdout()) > > ### Name: image.asc > ### Title: Displays a Color Image of an Object of Class 'asc' > ### Aliases: image.asc persp.asc contour.asc plot.asc > ### Keywords: hplot > > ### ** Examples > > > data(puechabon) > > # Case of a continuous variable: the elevation > my.map <- getkasc(puechabon$kasc, "Elevation") > image(my.map, main = "Elevation in Puechabon") > contour(my.map, add = TRUE) > > # use of the function plot.asc: adding points on the map > plot(my.map, plot.axes = {points(puechabon$locs[,c("X","Y")])}, + main = "Elevation") > > # Case of a factor: the aspect > asp <- getkasc(puechabon$kasc, "Aspect") > cl <- colasc(asp, NorthEast = "blue", SouthEast = "red", + SouthWest = "orange", NorthWest = "green") > > ## graphical display > image(asp, clfac = cl, main = "Aspect", xlab = "Lambert X", + ylab = "Lambert Y") > legend(706500, 3162000, legend = levels(asp), fill = cl, + cex = 0.7) > > opar<-par(mar = c(0,0,3,0), bg = "slategray") > persp(my.map, scale = FALSE, box = FALSE, border = NA, shade = 0.75, + col = "darkolivegreen3", expand = 2, theta = -60, phi = 30, + main = "The topography of Puechabon") > par(opar) > > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "image.sahrlocs" > > ### * image.sahrlocs > > flush(stderr()); flush(stdout()) > > ### Name: image.sahrlocs > ### Title: Graphical Display of the Habitat Composition of the Home Ranges > ### of Animals Monitored Using Radio-Tracking > ### Aliases: image.sahrlocs > ### Keywords: spatial multivariate > > ### ** Examples > > data(puechabon) > sahr <- puechabon$sahr > sahr ************** Object of type sahrlocs ************** The area of interest is a 121 * 111 raster matrix 4 animals are available : [1] "Brock" "Calou" "Chou" "Jean" the following variables are available for the study area: [1] "Elevation" "Aspect" "Slope" "Herbaceous" the following variables are available for each monitored animal: NULL > > ## Displays all the variables for a given animal > image(sahr, ani = "Chou") > > ## Displays all the animals for a given variable > image(sahr, var = "Elevation") > > ## Load and displays the relocations of the animals > locs <- puechabon$locs[,c(1,4:5)] > image(sahr, var = "Elevation", dfidxy = locs, pch = 21) > > > > cleanEx(); ..nameEx <- "import.asc" > > ### * import.asc > > flush(stderr()); flush(stdout()) > > ### Name: import.asc > ### Title: Arcview ASCII Raster File Importation And Exportation > ### Aliases: import.asc export.asc as.asc asc print.asc > ### Keywords: file > > ### ** Examples > > ## Not run: > ##D ## Importation of asc files: numeric > ##D ## Path of the file to be imported > ##D (file1 <- paste(system.file(package = "adehabitat"), > ##D "ascfiles/Elevation.asc", sep = "/")) > ##D > ##D el <- import.asc(file1) > ##D image(el) > ##D el > ##D > ##D ## Importation of asc files: factor > ##D (file2 <- paste(system.file(package = "adehabitat"), > ##D "ascfiles/Aspect.asc", sep = "/")) > ##D (levelfile <- paste(system.file(package = "adehabitat"), > ##D "ascfiles/Aspect.txt", sep = "/")) > ##D asp <- import.asc(file2, lev = levelfile, type = "factor") > ##D image(asp) > ##D asp > ##D > ##D ## map of white noise > ##D wafwaf <- matrix(rnorm(10000), 100, 100) > ##D wafwaf <- as.asc(wafwaf) > ##D image(wafwaf) > ##D > ##D ## exportation of a map > ##D export.asc(wafwaf, "foo.asc") > ##D > ##D ## remove the created file: > ##D file.remove("foo.asc") > ## End(Not run) > > > > cleanEx(); ..nameEx <- "join.asc" > > ### * join.asc > > flush(stderr()); flush(stdout()) > > ### Name: join.asc > ### Title: Finds the Value of Mapped Variables at some Specified Locations > ### (Spatial Join) > ### Aliases: join.asc join.kasc > ### Keywords: programming hplot > > ### ** Examples > > data(puechabon) > x <- puechabon$kasc > > ## for each relocation, finds the values of the variables in x > toto <- join.kasc(pts = cbind(puechabon$locs$X, puechabon$locs$Y), x) > toto[1:4,] Elevation Aspect Slope Herbaceous 1 108 NorthWest 19.39472 0.2 2 172 NorthWest 23.67911 0.2 3 121 NorthEast 20.16249 0.2 4 113 NorthWest 22.39815 0.2 > > > > cleanEx(); ..nameEx <- "kasc2df" > > ### * kasc2df > > flush(stderr()); flush(stdout()) > > ### Name: kasc2df > ### Title: Conversion of Objects of Class kasc > ### Aliases: kasc2df df2kasc > ### Keywords: multivariate NA > > ### ** Examples > > data(puechabon) > kasc <- puechabon$kasc > > # Display the kasc object > image(kasc) > > # Preparation for Principal component analysis > x <- kasc2df(kasc) > x$tab <- x$tab[, (names(x$tab) != "Aspect")] > > # Principal component analysis > ana <- dudi.pca(x$tab, scannf = FALSE) > > s.arrow(ana$co) > s.label(ana$li, clab = 0) > > ## Map of the scores of the rows > scores <- df2kasc(ana$li, x$index, kasc) > image(scores) > > > > cleanEx(); ..nameEx <- "kasc2spixdf" > > ### * kasc2spixdf > > flush(stderr()); flush(stdout()) > > ### Name: kasc2spixdf > ### Title: Conversion of maps from/to the package "sp" > ### Aliases: kasc2spixdf asc2spixdf spixdf2kasc area2sr sr2area attsr2area > ### traj2spdf traj2sldf > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D if (require(sp) { > ##D > ##D ######################################### > ##D ## > ##D ## Conversion kasc -> SpatialPixelsDataFrame > ##D ## > ##D > ##D data(puechabon) > ##D toto <- kasc2spixdf(puechabon$kasc) > ##D image(toto) > ##D summary(toto) > ##D > ##D #### and conversely > ##D toto <- spixdf2kasc(toto) > ##D image(toto) > ##D hist(toto) > ##D > ##D data(meuse.grid) > ##D m <- SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], > ##D data = meuse.grid) > ##D i <- spixdf2kasc(m) > ##D image(i) > ##D > ##D ### conversion asc -> SpatialPixelsDataFrame > ##D cuicui <- asc2spixdf(getkasc(toto,1)) > ##D image(cuicui) > ##D > ##D ######################################### > ##D ## > ##D ## Conversion area -> SpatialRings > ##D ## > ##D > ##D data(elec88) > ##D ar <- as.area(elec88$area) > ##D plot(ar) > ##D toto <- area2sr(ar) > ##D plot(toto) > ##D > ##D ######################################### > ##D ## > ##D ## Conversion SpatialRings -> area > ##D ## > ##D > ##D ## First create an object of class "SpatialRingsDataFrame" > ##D data(ncshp) > ##D nc1 <- as.SpatialRings.Shapes(nc.shp$Shapes, as.character(nc.shp$att.data$FIPS)) > ##D plotSpatialRings(nc1) > ##D df <- nc.shp$att.data > ##D rownames(df) <- as.character(nc.shp$att.data$FIPS) > ##D ncSRDF <- SpatialRingsDataFrame(nc1, df) > ##D > ##D ## and then conversion: > ##D coincoin <- sr2area(ncSRDF) > ##D ## please note the warnings > ##D > ##D plot(coincoin) > ##D ## gets the attributes > ##D haha <- attsr2area(ncSRDF) > ##D area.plot(coincoin, values = df$SID74/df$BIR74) > ##D > ##D ######################################### > ##D ## > ##D ## Conversion traj -> SpatialPointsDataFrame > ##D ## > ##D > ##D data(puechcirc) > ##D plot(puechcirc) > ##D > ##D toto <- traj2spdf(puechcirc) > ##D plot(toto) > ##D > ##D ######################################### > ##D ## > ##D ## Conversion traj -> SpatialLinesDataFrame > ##D ## > ##D > ##D data(puechcirc) > ##D plot(puechcirc) > ##D > ##D toto <- traj2sldf(puechcirc) > ##D plot(toto) > ##D > ##D } > ## End(Not run) > > > > cleanEx(); ..nameEx <- "kernelUD" > > ### * kernelUD > > flush(stderr()); flush(stdout()) > > ### Name: kernelUD > ### Title: Estimation of Kernel Home-Range > ### Aliases: kernelUD print.khr image.khr plotLSCV getvolumeUD kernel.area > ### getverticeshr kernelbb plot.kver > ### Keywords: spatial > > ### ** Examples > > > data(puechabon) > loc <- puechabon$locs[, c("X", "Y")] > id <- puechabon$locs[, "Name"] > > ## Estimation of UD for the four animals > ud <- kernelUD(loc, id) > ud ********** Utilization distribution of Animals ************ Type: probability density UD have been estimated using the kernel method for the following animals: [1] Brock Calou Chou Jean The smoothing parameter was estimated by the reference method (ad hoc) Each animal is a component of the list, and for each animal, the following elements are available: $UD The utilization distribution (object of class "asc") $locs The relocations of the animal $h The value of the smoothing parameter > > image(ud) ## Note that the contours > ## corresponds to values of probability density > udvol <- getvolumeUD(ud) > image(udvol) > ## Here, the contour corresponds to the > ## home ranges estimated at different probability > ## levels (i.e. the contour 90 corresponds to the 90 percent > ## kernel home-range) > ## udvol describes, for each cell of the grid, > ## the smaller home-range to which it belongs > > ## Calculation of the 95 percent home range > ver <- getverticeshr(ud, 95) > elev <- getkasc(puechabon$kasc, "Elevation") # Map of the area > image(elev) > plot(ver, add=TRUE) > legend(696500, 3166000, legend = names(ver), fill = rainbow(4)) > > ## Example of estimation using LSCV > udbis <- kernelUD(loc, id, h = "LSCV") > image(udbis) > > ## Compare the estimation with ad hoc and LSCV method > ## for the smoothing parameter > (cuicui1 <- kernel.area(loc, id)) ## ad hoc Brock Calou Chou Jean 20 15.50560 12.33984 18.82767 14.77481 25 20.35111 15.97852 24.34613 19.20725 30 25.77807 19.85449 30.18920 24.37843 35 31.59267 24.04688 36.35689 30.28835 40 37.79491 28.55566 43.17380 36.19827 45 44.77243 33.53906 49.99072 43.58567 50 52.13760 39.07617 57.78148 50.97308 55 60.27804 45.40430 66.54609 60.57670 60 69.19376 52.68164 76.28454 70.91906 65 78.88477 60.82910 86.99684 83.47765 70 89.93251 69.76758 99.65682 97.51371 75 102.91845 79.73438 114.26450 114.50474 80 118.42406 91.20410 132.11833 135.18947 85 138.19370 105.20508 156.13985 161.78411 90 165.32851 123.79395 194.44442 203.89231 95 209.71331 153.14062 261.63974 281.46004 > plot(cuicui1) > (cuicui2 <- kernel.area(loc, id, h = "LSCV")) ## LSCV Brock Calou Chou Jean 20 4.651681 5.141602 7.790762 4.432442 25 6.202242 6.881836 10.063067 5.909922 30 8.140443 8.859375 12.984603 7.387403 35 10.078643 11.074219 15.906138 8.864883 40 12.016844 13.684570 19.476904 11.081104 45 14.342685 16.453125 23.372284 13.297325 50 16.668525 19.538086 27.916895 16.252285 55 19.382006 23.018555 33.110736 19.945987 60 22.483127 26.973633 39.278423 24.378428 65 25.971888 31.482422 46.095339 29.549610 70 29.848290 36.386719 53.886100 35.459532 75 34.306151 41.923828 62.975322 42.846935 80 39.926933 48.251953 74.012234 51.711818 85 46.710635 55.924805 87.321452 62.792921 90 55.820178 65.733398 104.526050 76.828986 95 70.356683 80.367188 129.846025 99.729934 > plot(cuicui2) > > ## Diagnostic of the cross-validation > plotLSCV(udbis) > > ## Use of the same4all argument: the same grid > ## is used for all animals > udbis <- kernelUD(loc, id, same4all = TRUE) > image(udbis) > > ## And finally, estimation of the UD on a map > ## (e.g. for subsequent analyses on habitat selection) > elev <- getkasc(puechabon$kasc, "Elevation") > opar <- par(mfrow = c(2, 2), mar = c(0, 0, 2, 0)) > cont <- getcontour(elev) > > for (i in 1:length(udbis)) { + image(elev, main = names(udbis)[i], axes = FALSE) + points(udbis[[i]]$locs, pch = 21, bg = "white", col = "black") + } > > ## Measures the UD in each pixel of the map > udbis <- kernelUD(loc, id, grid = elev) > opar <- par(mfrow = c(2, 2), mar = c(0, 0, 2, 0)) > for (i in 1:length(udbis)) { + image(udbis[[i]]$UD, main = names(udbis)[i], axes = FALSE) + box() + polygon(cont[, 2:3]) + } > par(opar) > > > > ############################################### > ############################################### > ############################################### > ### > ### Kernel estimation: a brownian > ### bridge approach > > ## Not run: > ##D > ##D ## loads the data > ##D data(puechcirc) > ##D > ##D ## gets one circuit > ##D x <- getburst(puechcirc, burst = "CH930824") > ##D > ##D ## fits the home range > ##D (tata <- kernelbb(x, 10, 10, same4all = TRUE)) > ##D image(tata) > ##D lines(x$x, x$y, lwd = 2, col = "red") > ##D > ##D ## Image of a brownian bridge. Fit with two relocations: > ##D fac <- factor(c("a", "a")) > ##D xx <- c(0,1) > ##D yy <- c(0,1) > ##D date <- c(0,1) > ##D class(date) <- c("POSIXt", "POSIXct") > ##D tr <- as.traj(fac, data.frame(x = xx,y = yy), date) > ##D > ##D ## Use of different smoothing parameters > ##D sig1 <- c(0.05, 0.1, 0.2, 0.4, 0.6) > ##D sig2 <- c(0.05, 0.1, 0.2, 0.5, 0.7) > ##D > ##D y <- list() > ##D for (i in 1:5) { > ##D for (j in 1:5) { > ##D k <- paste("s1=", sig1[i], ", s2=", sig2[j], sep = "") > ##D y[[k]]<-kernelbb(tr, sig1[i], sig2[j])[[1]]$UD > ##D } > ##D } > ##D > ##D ## Displays the results > ##D opar <- par(mar = c(0,0,2,0), mfrow = c(5,5)) > ##D foo <- function(x) > ##D { > ##D image(y[[x]], main = names(y)[x], axes = F) > ##D points(tr[,c("x","y")], pch = 16, col = "red") > ##D } > ##D lapply(1:length(y), foo) > ##D > ##D par(opar) > ##D > ## End(Not run) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "kselect" > > ### * kselect > > flush(stderr()); flush(stdout()) > > ### Name: kselect > ### Title: K-Select Analysis: a Method to Analyse the Habitat Selection by > ### Animals > ### Aliases: kselect print.kselect hist.kselect kplot.kselect plot.kselect > ### Keywords: multivariate hplot > > ### ** Examples > > > ## Not run: > ##D ## Loads the data > ##D data(puechabon) > ##D sahr <- puechabon$sahr > ##D > ##D ## prepares the data for the kselect analysis > ##D x <- sahrlocs2kselect(sahr) > ##D tab <- x$tab > ##D > ##D ## Example of analysis with two variables: the slope and the elevation. > ##D ## Have a look at the use and availability of the two variables > ##D ## for the 4 animals > ##D tab <- tab[,((names(tab) == "Slope")|(names(tab) == "Elevation"))] > ##D tab <- scale(tab) > ##D tmp <- split.data.frame(tab, x$factor) > ##D wg <- split(x$weight, x$factor) > ##D opar <- par(mfrow = n2mfrow(nlevels(x$factor))) > ##D for (i in names(tmp)) > ##D s.distri(scale(tmp[[i]]), wg[[i]]) > ##D par(opar) > ##D > ##D ## We call a new graphic window > ##D x11() > ##D ## A K-select analysis > ##D acp <- dudi.pca(tab, scannf = FALSE, nf = 2) > ##D kn <- kselect(acp, x$factor, x$weight, > ##D scannf = FALSE, nf = 2) > ##D > ##D # use of the generic function scatter > ##D scatter(kn) > ##D > ##D # Displays the first factorial plane > ##D kplot(kn) > ##D kplot(kn, cellipse = 0, cpoint = 0) > ##D kplot(kn, addval = FALSE, cstar = 0) > ##D > ##D # this factorial plane can be compared with > ##D # the other graph to see the rotation proposed by > ##D # the analysis > ##D graphics.off() > ##D > ##D # Displays the first factorial axis > ##D hist(kn) > ##D > ##D # Displays the second factorial axis > ##D hist(kn, xax = 2) > ##D > ##D # Summary of the analysis > ##D plot(kn) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "labcon" > > ### * labcon > > flush(stderr()); flush(stdout()) > > ### Name: labcon > ### Title: Labelling Connected Features > ### Aliases: labcon > ### Keywords: spatial > > ### ** Examples > > data(puechabon) > hr <- getsahrlocs(puechabon$sahr, "hr") > u <- getkasc(hr, "Jean") > image(u) > > ## numbering of the connected components > p <- labcon(u) > nlevels(p) [1] 2 > image(p) > > ## stores the first component > c1 <- p > c1[c1 != 1] <- NA > image(c1) > > ## stores the second component > c2 <- p > c2[c2 != 2] <- NA > image(c2) > > > > cleanEx(); ..nameEx <- "lowres" > > ### * lowres > > flush(stderr()); flush(stdout()) > > ### Name: lowres > ### Title: Reducing the Resolution of a Map > ### Aliases: lowres lowres.asc lowres.kasc > ### Keywords: spatial > > ### ** Examples > > data(puechabon) > kasc <- puechabon$kasc > > ## The initial image > image(kasc) > > ## The transformed image > m <- lowres(kasc, np = 4) > image(m) > > > > > cleanEx(); ..nameEx <- "mahasuhab" > > ### * mahasuhab > > flush(stderr()); flush(stdout()) > > ### Name: mahasuhab > ### Title: Habitat Suitability Mapping with Mahalanobis Distances. > ### Aliases: mahasuhab > ### Keywords: spatial multivariate > > ### ** Examples > > ## loads the data > data(lynxjura) > ka <- lynxjura$map > lo <- lynxjura$locs[,1:2] > > ## We first scale the maps > df <- kasc2df(ka) > pc <- dudi.pca(df$tab, scannf=FALSE) > tab <- pc$tab > ka <- df2kasc(tab, df$index, ka) > > ## habitat suitability mapping > hsm <- mahasuhab(ka, lo, type = "probability") > plot(hsm, main = "Habitat suitability map for the Lynx", + plot.axes = { points(lo, pch = 16, cex=0.5)}) > > > > cleanEx(); ..nameEx <- "mcp" > > ### * mcp > > flush(stderr()); flush(stdout()) > > ### Name: mcp > ### Title: Estimation of the Home Range Using the Minimum Convex Polygon > ### Estimator > ### Aliases: mcp plot.hrsize mcp.area > ### Keywords: hplot > > ### ** Examples > > data(puechabon) > locs <- puechabon$locs > > cp <- mcp(locs[,4:5], locs[,1]) > > ## Plot the home ranges > opar <- par(mar = c(0,0,0,0)) > area.plot(cp) > > ## ... And the relocations > points(locs[,4:5], pch = 16, col = as.numeric(locs[,1])) > par(opar) > > ## Computation of the home-range size: > if (require(gpclib)) { + (cuicui1 <- mcp.area(locs[,4:5], locs[,1])) + plot(cuicui1) + } Loading required package: gpclib General Polygon Clipper Library for R (version 1.3 ) Type 'class ? gpc.poly' for help > > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "mcp.rast" Warning in detach("package:gpclib") : package:gpclib is required by package:adehabitat (still attached) > > ### * mcp.rast > > flush(stderr()); flush(stdout()) > > ### Name: mcp.rast > ### Title: Converts a Polygon to Raster > ### Aliases: mcp.rast > ### Keywords: spatial > > ### ** Examples > > data(puechabon) > toto <- puechabon$kasc > loc <- puechabon$locs > > ## gets the coordinates of the relocations for the wild boar #1 > wb1 <- loc[loc$Name == "Chou",] > wb1 <- cbind(wb1$X, wb1$Y) > nbpol <- chull(wb1) > xycoord <- wb1[nbpol,] > > ## rasterization of wb1 > tutu <- mcp.rast(xycoord, toto) > image(tutu) > > polygon(xycoord, lwd = 2) > > > > cleanEx(); ..nameEx <- "morphology" > > ### * morphology > > flush(stderr()); flush(stdout()) > > ### Name: morphology > ### Title: Morphology: Erosion or Dilatation of Features on a Raster Map > ### Aliases: morphology > ### Keywords: spatial > > ### ** Examples > > data(puechabon) > a <- getkasc(puechabon$kasc,"Elevation") > > ## dilatation > toto1 <- morphology(a, operation = "dilate", nt = 1) > toto2 <- morphology(a, operation = "dilate", nt = 2) > toto3 <- morphology(a, operation = "dilate", nt = 3) > toto5 <- morphology(a, operation = "dilate", nt = 5) > image(toto5, col = "red") > image(toto3, add = TRUE, col = "orange") > image(toto2, add = TRUE, col = "yellow") > image(toto1, add = TRUE, col = "green") > image(a, add = TRUE) > > ## erosion > image(a, col = 1) > for (i in 1:19) { + toto <- morphology(a, operation = "erode", nt = i) + image(toto, add = TRUE, col = palette()[(i+1)%%8]) + } > > > > > cleanEx(); ..nameEx <- "niche.test" > > ### * niche.test > > flush(stderr()); flush(stdout()) > > ### Name: niche.test > ### Title: Monte-Carlo Test on Parameters of the Ecological Niche > ### Aliases: niche.test > ### Keywords: multivariate > > ### ** Examples > > ## Not run: > ##D data(lynxjura) > ##D > ##D ## We keep only "wild" indices. > ##D tmp=lynxjura$loc[,4]!="D" > ##D niche=niche.test(lynxjura$map, > ##D lynxjura$locs[tmp, c("X", "Y")], > ##D side = "bottom") > ##D names(niche) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "perarea" > > ### * perarea > > flush(stderr()); flush(stdout()) > > ### Name: perarea > ### Title: Compute Areas and Perimeters of Objects of Class "area" > ### Aliases: perarea ararea > ### Keywords: hplot > > ### ** Examples > > > data(puechabon) > locs <- puechabon$locs > > cp <- mcp(locs[,4:5], locs[,1]) > > perarea(cp) Brock Calou Chou Jean 3054.103 1749.217 3248.091 2968.166 > > if (require(gpclib)) + ararea(cp) Loading required package: gpclib General Polygon Clipper Library for R (version 1.3 ) Type 'class ? gpc.poly' for help Brock Calou Chou Jean 226467.0 416881.5 719320.5 558841.5 > > > > > cleanEx(); ..nameEx <- "plot.area" Warning in detach("package:gpclib") : package:gpclib is required by package:adehabitat (still attached) > > ### * plot.area > > flush(stderr()); flush(stdout()) > > ### Name: plot.area > ### Title: Graphical Display of Objects of Class "area" > ### Aliases: plot.area > ### Keywords: hplot > > ### ** Examples > > > ## Loading the relocations of wild boars > ## monitored using radio-tracking > data(puechabon) > locs <- puechabon$locs > el <- getkasc(puechabon$kasc, "Elevation") > > ## Estimation of the MCP home ranges of the animals > cp <- mcp(locs[,4:5], locs[,1]) > > ## Use of plot.area to display the results > plot(cp) > > ## different colors: > color <- c("red", "blue", "green", "yellow") > lev <- levels(cp[,1]) > image(el) > plot(cp, colpol = color, add = TRUE) > legend(697198, 3165529, legend = lev, fill = color) > > ## or: > image(el) > plot(cp, colborder = color, colpol = NA, add = TRUE) > legend(697198, 3165529, legend = lev, fill = color) > > ## plots one animal > image(el) > plot(cp, which = "Brock", add = TRUE) > > > > > cleanEx(); ..nameEx <- "plot.sahrlocs" > > ### * plot.sahrlocs > > flush(stderr()); flush(stdout()) > > ### Name: plot.sahrlocs > ### Title: Exploratory Analysis of Habitat Selection > ### Aliases: plot.sahrlocs print.plotsahr > ### Keywords: hplot math > > ### ** Examples > > data(puechabon) > sahr <- puechabon$sahr > toto <- plot(sahr) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: > ### Note that the wild boars named Brock and Calou > ### have only one herbaceous cover class available > ### (the second one), and they use it exclusively. > ### So they have identical > ### selection ratios (that's why the curve of Brock > ### does not appear: it is hidden behind the curve > ### of the boar named Calou). > > toto ***** List of class "plotsahr" ***** Selection ratios are computed for the following variables: Elevation Aspect Slope Herbaceous each variable is a component of the list > toto$Elevation ************** Manly's Selection ratios for design II ******** 1. Test of identical use of habitat by all animals (Classical KhiČ performed on the used matrix): Khi2L1 df pvalue 146.1114 9.0000 0.0000 2. Test of overall habitat selection: Khi2L2 df pvalue 391.5605 12.0000 0.0000 3. Test of hypothesis that animals are on average using resources in proportion to availability, irrespective of whether they are the same or not (Khi2L2 - Khi2L1): Khi2L2MinusL1 df pvalue 245.4491 3.0000 0.0000 Table of selection ratios: Available Used Wi SE IClower ICupper (64.6,168] 0.22585065 0.2385252 1.0561192 0.1772095 0.6135 1.4987 (168,272] 0.35122174 0.2761475 0.7862483 0.1277354 0.4672 1.1053 (272,376] 0.35944280 0.4853273 1.3502213 0.2165410 0.8094 1.8911 (376,479] 0.06348481 0.0000000 0.0000000 0.0000000 0.0000 0.0000 Bonferroni classement Based on 95 % confidence intervals on the differences of Wi : habitat (272,376] (64.6,168] (168,272] (376,479] (272,376] ---------------------------------- (64.6,168] ---------------------------------- (168,272] ---------------------------------- (376,479] ----------- > > > > > cleanEx(); ..nameEx <- "predict.enfa" > > ### * predict.enfa > > flush(stderr()); flush(stdout()) > > ### Name: predict.enfa > ### Title: Habitat Suitability Maps Built from the ENFA > ### Aliases: predict.enfa > ### Keywords: multivariate > > ### ** Examples > > ## Not run: > ##D data(lynxjura) > ##D > ##D map <- lynxjura$map > ##D > ##D ## We keep only "wild" indices. > ##D tmp <- lynxjura$loc[,4] != "D" > ##D locs <- lynxjura$locs[tmp, c("X","Y")] > ##D dataenfa1 <- data2enfa(map, locs[tmp, c("X","Y")]) > ##D > ##D (enfa1 <- enfa(dataenfa1$tab, dataenfa1$pr, > ##D scannf = FALSE)) > ##D > ##D ## Compute the prediction > ##D pred <- predict(enfa1, dataenfa1$index, dataenfa1$attr) > ##D image(pred) > ##D contour(pred, col="green", add=T) > ##D points(locs, col = "red", pch = 16) > ##D ## Lighter areas are the most preferred areas > ## End(Not run) > > > > cleanEx(); ..nameEx <- "rand.kselect" > > ### * rand.kselect > > flush(stderr()); flush(stdout()) > > ### Name: rand.kselect > ### Title: Test of the Third-Order Habitat Selection > ### Aliases: rand.kselect print.rand.kselect > ### Keywords: multivariate > > ### ** Examples > > ## Not run: > ##D ## Loads the data > ##D data(puechabon) > ##D sahr <- puechabon$sahr > ##D > ##D ## prepares the data for the kselect analysis: only two variables are kept > ##D x <- sahrlocs2kselect(sahr) > ##D tab <- x$tab > ##D dud <- dudi.mix(tab, scannf = FALSE, nf = 2) > ##D > ##D ## the randomisation tests > ##D ## be patient, this can be very long on some machines > ##D (te <- rand.kselect(dud, x$factor, x$weight, nrep = 50)) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "randtest.enfa" > > ### * randtest.enfa > > flush(stderr()); flush(stdout()) > > ### Name: randtest.enfa > ### Title: Randomisation Test for the Ecological Niche Factor Analysis > ### Aliases: randtest.enfa > ### Keywords: multivariate > > ### ** Examples > > ## Not run: > ##D data(chamois) > ##D locs <- chamois$locs > ##D map <- chamois$map > ##D map$Vegetation <- NULL > ##D en <- enfa(map, locs, scannf=F) > ##D (tutu <- randtest(en)) > ##D plot(tutu) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "sahrlocs2kselect" > > ### * sahrlocs2kselect > > flush(stderr()); flush(stdout()) > > ### Name: sahrlocs2kselect > ### Title: Preparation of K-Select Analysis > ### Aliases: sahrlocs2kselect > ### Keywords: multivariate > > ### ** Examples > > data(puechabon) > sahr <- puechabon$sahr > s <- sahrlocs2kselect(sahr) > > # 1. PCA of the dataset > pc <- dudi.mix(s$tab, scannf = FALSE) > > # 2. k-select analysis > kn <- kselect(pc, s$factor, s$weight, scannf = FALSE) > > scatter(kn) > > > > cleanEx(); ..nameEx <- "sahrlocs2niche" > > ### * sahrlocs2niche > > flush(stderr()); flush(stdout()) > > ### Name: sahrlocs2niche > ### Title: OMI Analysis of Radio-Tracking Data > ### Aliases: sahrlocs2niche > ### Keywords: multivariate > > ### ** Examples > > data(puechabon) > sahr <- puechabon$sahr > > s <- sahrlocs2niche(sahr, used = "locs") > > # 1. dudi.mix of the dataset > pc <- dudi.mix(s$tab, scannf = FALSE) > > # 2. niche analysis > n <- niche(pc, s$y, scannf = FALSE) > > plot(n) > > > > cleanEx(); ..nameEx <- "scatter.enfa" > > ### * scatter.enfa > > flush(stderr()); flush(stdout()) > > ### Name: scatter.enfa > ### Title: Scatter Plot of the Results of the ENFA > ### Aliases: scatter.enfa > ### Keywords: multivariate hplot > > ### ** Examples > > ## Not run: > ##D ## Not run: > ##D data(lynxjura) > ##D > ##D map <- lynxjura$map > ##D > ##D ## We keep only "wild" indices. > ##D tmp <- lynxjura$locs[,4]!="D" > ##D locs <- lynxjura$locs[tmp, c("X","Y")] > ##D > ##D ## We perform a square root transformation > ##D ## of the variable to normalize it > ##D map[,4] <- sqrt(map[,4]) > ##D > ##D ## We perform the ENFA > ##D (enfa1 <- enfa(map, locs[tmp, c("X","Y")], > ##D scannf = FALSE)) > ##D scatter(enfa1) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "schoener" > > ### * schoener > > flush(stderr()); flush(stdout()) > > ### Name: schoener > ### Title: Compute Schoener's ratio > ### Aliases: schoener schoener.rtest > ### Keywords: math > > ### ** Examples > > > data(puechcirc) > puechcirc$date[1:10] [1] "1993-08-24 17:00:00 CEST" "1993-08-24 17:20:00 CEST" [3] "1993-08-24 17:30:00 CEST" "1993-08-24 17:40:00 CEST" [5] "1993-08-24 17:50:00 CEST" "1993-08-24 18:00:00 CEST" [7] "1993-08-24 18:10:00 CEST" "1993-08-24 18:20:00 CEST" [9] "1993-08-24 18:30:00 CEST" "1993-08-24 18:40:00 CEST" > > ## Relocations are taken every 10 minutes > ## For example we consider relocations as > ## neighbour when they are separated by a time > ## interval comprised between 5 and 15 minutes > schoener(puechcirc, keep = c(5*60, 15*60)) value n m CH930824 0.11283413 65 54 CH930827 0.08357815 53 43 JE930819 0.02026349 39 1 JE930827 0.09555405 47 38 > ## Not run: > ##D schoener.rtest(puechcirc, keep = c(5*60, 15*60)) > ## End(Not run) > > > > > > cleanEx(); ..nameEx <- "setmask" > > ### * setmask > > flush(stderr()); flush(stdout()) > > ### Name: setmask > ### Title: Applies a Mask on Objects of Class 'asc' or 'kasc' > ### Aliases: setmask > ### Keywords: spatial > > ### ** Examples > > > data(puechabon) > kasc <- puechabon$kasc > image(kasc) > elev <- getkasc(kasc, "Elevation") > slope <- getkasc(kasc, "Slope") > > ## ma is the mask: only areas with elevation > 250 m > ## are kept > ma <- elev > ma[ma < 250] <- NA > ma <- getascattr(elev, ma) > image(ma) > > ## The mask is applied on maps of slope > slp <- setmask(slope, ma) > image(slp) > > ## The mask is applied on all maps in kasc > im <- setmask(kasc, ma) > image(im) > > > > > cleanEx(); ..nameEx <- "speed" > > ### * speed > > flush(stderr()); flush(stdout()) > > ### Name: speed > ### Title: Computes the Speed Between Successive Relocations of an Animal > ### Aliases: speed > ### Keywords: spatial > > ### ** Examples > > > #### Computes the speed for each wild boar > #### monitored at Puechabon > data(puechcirc) > puechcirc ******** Data frame of class traj ********* Animal CH93 : 2 circuits (118 relocations) Animal JE93 : 2 circuits (86 relocations) Variables measured for each relocation: [1] id x y date burst > plot(puechcirc) > sp <- speed(puechcirc) > sp[1:4,] id x y date burst sp.x sp.y 1 CH93 700151 3158187 1993-08-24 17:00:00 CH930824 0.11666667 0.18083333 2 CH93 700291 3158404 1993-08-24 17:20:00 CH930824 -0.08333333 -0.10666667 3 CH93 700241 3158340 1993-08-24 17:30:00 CH930824 0.06666667 0.28666667 4 CH93 700281 3158512 1993-08-24 17:40:00 CH930824 -0.03500000 -0.04333333 speed dt 1 0.21520178 1200 2 0.13535960 600 3 0.29431653 600 4 0.05570258 600 > > > > > cleanEx(); ..nameEx <- "storemapattr" > > ### * storemapattr > > flush(stderr()); flush(stdout()) > > ### Name: storemapattr > ### Title: Store attributes of maps of class asc and kasc > ### Aliases: storemapattr > ### Keywords: programming > > ### ** Examples > > data(puechabon) > (kasc <- puechabon$kasc) Raster map of class "kasc": Cell size: 100 Number of rows: 121 Number of columns: 111 Variables measured: 1. Elevation: numeric 2. Aspect: factor 3. Slope: numeric 4. Herbaceous: numeric > > (toto <- storemapattr(kasc)) [1] 0 attr(,"xll") [1] 697000 attr(,"yll") [1] 3155000 attr(,"cellsize") [1] 100 attr(,"nrow") [1] 121 attr(,"ncol") [1] 111 attr(,"class") [1] "mapattr" > > > > > cleanEx(); ..nameEx <- "subsetmap" > > ### * subsetmap > > flush(stderr()); flush(stdout()) > > ### Name: subsetmap > ### Title: Storing a Part of a Map > ### Aliases: subsetmap subsetmap.asc subsetmap.kasc > ### Keywords: spatial > > ### ** Examples > > > data(puechabon) > kasc <- puechabon$kasc > el <- getkasc(kasc, "Elevation") > > ## limits of the new map: > xl <- c(701561, 704017) > yl <- c(3160560, 3162343) > > ## computation of the new map: > su <- subsetmap(el, xlim = xl, ylim = yl) > > ## Display > opar <- par(mar = c(0,0,0,0)) > layout(matrix(c(1,1,1,1,1,1,1,1,2), byrow = TRUE, ncol = 3)) > image(el, axes = FALSE) > polygon(c(xl[1], xl[2], xl[2], xl[1]), + c(yl[1], yl[1], yl[2], yl[2])) > image(su, axes = FALSE) > box() > > par(opar) > par(mfrow = c(1,1)) > > ### Gets this part for the whole kasc object > m <- subsetmap(kasc, xlim = xl, ylim = yl) > image(m) > > ## Not run: > ##D ## Interactive example > ##D su <- subsetmap(kasc) > ##D > ##D image(su) > ## End(Not run) > > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "wi" > > ### * wi > > flush(stderr()); flush(stdout()) > > ### Name: wi > ### Title: Computation of Selection Ratios for Habitat Selection Studies. > ### Aliases: widesI widesII widesIII print.wiI print.wiII print.wiIII > ### plot.wi wi wiI wiII wiIII > ### Keywords: hplot math > > ### ** Examples > > > ############################ > ## Example of moose (Manly et al., 2003, p.52) > ## Known available proportions on design I data > moose.avail <- c(0.34, 0.101, 0.104, 0.455) > moose.used <- c(25, 22, 30, 40) > names(moose.used) <- c("InBurnInterior", + "InBurnEdge", + "OutOfBurnEdge", + "OutOfBurnFurther") > names(moose.avail) <- names(moose.used) > ## Computation of wi > (wiRatio <- widesI(moose.used, moose.avail)) ************** Manly's Selection ratios for design I ******** Significance of habitat selection: Khi2L df pvalue 3.539806e+01 3.000000e+00 1.003749e-07 Table of ratios (p-values should be compared with Bonferroni level= 0.0125 ) used avail Wi SE.Wi P Bi InBurnInterior 0.214 0.340 0.628 0.111 0.001 0.110 InBurnEdge 0.188 0.101 1.862 0.358 0.016 0.326 OutOfBurnEdge 0.256 0.104 2.465 0.388 0.000 0.432 OutOfBurnFurther 0.342 0.455 0.751 0.096 0.010 0.132 Bonferroni classement Based on 95 % confidence intervals on the differences of Wi : habitat OutOfBurnEdge InBurnEdge OutOfBurnFurther InBurnInterior OutOfBurnEdge --------------------------- InBurnEdge --------------------------- OutOfBurnFurther ---------------------------------- InBurnInterior ---------------------------------- > > ## plot the values of the selection ratios > opar <- par(mfrow=c(2,2)) > plot(wiRatio) Hit to see next plot: > par(opar) > > > > ############################ > ## Example of Elk (Manly et al., 2003, p.62) > ## Estimated available proportions on design I data > elk.avail <- c(15, 61, 84, 40) > elk.used <- c(3, 90, 181, 51) > names(elk.used) <- c("0%", "1-25%", "26-75%", ">75%") > names(elk.avail) <- names(elk.used) > ## Computation of wi > (wiRatio <- widesI(elk.used, elk.avail, avknown=FALSE)) ************** Manly's Selection ratios for design I ******** Significance of habitat selection: Khi2L df pvalue 2.196498e+01 3.000000e+00 6.633481e-05 Table of ratios (p-values should be compared with Bonferroni level= 0.0125 ) used avail Wi SE.Wi P Bi 0% 0.009 0.075 0.123 0.077 0.000 0.039 1-25% 0.277 0.305 0.908 0.127 0.467 0.289 26-75% 0.557 0.420 1.326 0.128 0.011 0.422 >75% 0.157 0.200 0.785 0.150 0.151 0.250 Bonferroni classement Based on 95 % confidence intervals on the differences of Wi : habitat 26-75% 1-25% >75% 0% 26-75% --------------------- 1-25% --------------------- >75% --------------------- 0% ---- > > ## plot the values of the selection ratios > opar <- par(mfrow=c(2,2)) > plot(wiRatio) Hit to see next plot: > par(opar) > > > > ############################ > ## Example of Bighorn (Manly et al., 2003, p.67) > ## Known available proportions on design II data > data(bighorn) > ## Computation of wi > (wi <- widesII(bighorn$used, bighorn$availT, alpha = 0.1)) ************** Manly's Selection ratios for design II ******** 1. Test of identical use of habitat by all animals (Classical KhiČ performed on the used matrix): Khi2L1 df pvalue 9.921335e+01 4.500000e+01 5.879911e-06 2. Test of overall habitat selection: Khi2L2 df pvalue 785.6926 54.0000 0.0000 3. Test of hypothesis that animals are on average using resources in proportion to availability, irrespective of whether they are the same or not (Khi2L2 - Khi2L1): Khi2L2MinusL1 df pvalue 686.4793 9.0000 0.0000 Table of selection ratios: Available Used Wi SE IClower ICupper Riparian 0.06 0.00000000 0.0000000 0.00000000 0.0000 0.0000 Conifer 0.13 0.01348315 0.1037165 0.03663257 0.0094 0.1981 MtShrub1 0.16 0.02022472 0.1264045 0.03623779 0.0331 0.2197 Aspen 0.15 0.04044944 0.2696629 0.08111987 0.0607 0.4786 RockOutcrop 0.06 0.03146067 0.5243446 0.21340985 -0.0254 1.0741 Bitterbrush 0.17 0.14157303 0.8327826 0.21098200 0.2893 1.3762 Windblown 0.12 0.10337079 0.8614232 0.10538673 0.5900 1.1329 MtShrub2 0.04 0.13932584 3.4831461 0.47088086 2.2702 4.6961 PresBurn 0.09 0.40000000 4.4444444 0.40657899 3.3972 5.4917 Clearcut 0.02 0.11011236 5.5056180 1.71723256 1.0823 9.9289 Bonferroni classement Based on 90 % confidence intervals on the differences of Wi : habitat Clearcut PresBurn MtShrub2 Windblown Bitterbrush RockOutcrop Aspen MtShrub1 Conifer Riparian Clearcut ------------------------------------------------------------------- PresBurn ------------------------------ MtShrub2 ------------------------------ Windblown ---------- ------------------------------------- Bitterbrush ---------- -------------------------------------------- --------- RockOutcrop ---------- ------------------------------------------------------------------------- Aspen ---------------------------------------------------- MtShrub1 --------------------------------------- Conifer -------------------------------------------------------------- Riparian ------------- ------------------- > > ## plot the values of the selection ratios > opar <- par(mfrow=c(2,2)) > plot(wi) Hit to see next plot: > > ############################ > ## Example of Bighorn (Manly et al., 2003, p.74) > ## Estimated available proportions on design II data > ## Computation of wi > (wi <- widesII(bighorn$used, bighorn$availE, avknown = FALSE, alpha = 0.1)) ************** Manly's Selection ratios for design II ******** 1. Test of identical use of habitat by all animals (Classical KhiČ performed on the used matrix): Khi2L1 df pvalue 9.921335e+01 4.500000e+01 5.879911e-06 2. Test of overall habitat selection: TrickyKhi2 df pvalue 373.075 54.000 0.000 3. Test of hypothesis that animals are on average using resources in proportion to availability, irrespective of whether they are the same or not (Khi2L2 - Khi2L1): Khi2L2MinusL1 df pvalue 273.8617 9.0000 0.0000 Table of selection ratios: Available Used Wi SE IClower ICupper Riparian 0.084 0.00000000 0.0000000 NaN NaN NaN Conifer 0.104 0.01348315 0.1296456 0.05173025 -0.0036 0.2629 MtShrub1 0.164 0.02022472 0.1233215 0.03949683 0.0216 0.2251 Aspen 0.160 0.04044944 0.2528090 0.08441413 0.0354 0.4702 RockOutcrop 0.056 0.03146067 0.5617978 0.27122678 -0.1368 1.2604 Bitterbrush 0.184 0.14157303 0.7694187 0.22022484 0.2022 1.3367 Windblown 0.136 0.10337079 0.7600793 0.15273415 0.3667 1.1535 MtShrub2 0.032 0.13932584 4.3539326 1.62487397 0.1685 8.5393 PresBurn 0.056 0.40000000 7.1428571 1.96652096 2.0774 12.2083 Clearcut 0.024 0.11011236 4.5880150 2.33922053 -1.4374 10.6134 Bonferroni classement Based on 90 % confidence intervals on the differences of Wi : habitat PresBurn Clearcut MtShrub2 Bitterbrush Windblown RockOutcrop Aspen Conifer MtShrub1 Riparian PresBurn ------------------------------ Clearcut ------------------------------------------------------------------------------------------------------- MtShrub2 ------------------------------------------------------------------------------------------------------- Bitterbrush ----------------------------------------------------------------------------------- Windblown ---------------------------------------------------------------- RockOutcrop --------------------------------------------------------------------------------------------- Aspen --------------------------------------------------------------------------------------------- Conifer --------------------------------- ------------------------------------------------- MtShrub1 --------------------------------- --------------------------------------- Riparian -------------------- ----------------------------- ---------- > > ## plot the values of the selection ratios > plot(wi) > > par(opar) > > ############################ > ## Example of Wild boar > ## Estimated available proportions on design III data > data(puechdesIII) > used <- puechdesIII$used > available <- puechdesIII$available > > ## calculation of the selectio ratios > ## with sampled availability > (i <- widesIII(used,available, avknown = FALSE, alpha = 0.1)) ************** Manly's Selection ratios for design III ******** 1. Test of habitat selection for each animal: Khi2Lj df pvalue Calou 8.2568824 2 0.016107969 Celi 0.6556429 2 0.720491653 Kinou 2.6219247 2 0.269560518 Lucette 2.9313066 2 0.230927083 Schnock 9.1833125 1 0.002442316 Suzanne 6.7392525 2 0.034402492 2. Test of overall habitat selection: Khi2L df pvalue 30.388321591 11.000000000 0.001376594 Table of selection ratios: Wi SE IClower ICupper <180 1.4675229 0.05294992 1.3548 1.5802 180-250 0.5654921 0.08591130 0.3827 0.7483 >250 0.6905348 0.13478337 0.4037 0.9774 Bonferroni classement Based on 90 % confidence intervals on the differences of Wi : habitat <180 >250 180-250 <180 ------ >250 --------------- 180-250 --------------- > > opar <- par(mfrow = c(2,2)) > plot(i) Hit to see next plot: > par(opar) > > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > ### *