Description Usage Arguments Details Value Author(s) Examples
View source: R/select.window.R
Selection of cells (or sites) around a focal cell. Cells must have have xy coordinates. Users should define a 'radius' from the focal cell that will define the window
1 | select.window(xf, yf, radius = 1, xydata)
|
xf |
The x-coordinate of the focal cell. |
yf |
The y-coordinate of the focal cell. |
radius |
The radius that define the window to select neighbor cells. |
xydata |
A matrix-like object. The first and second columns of data must have x and y coordinates, respectively. The remaining columns must contain species or other atributes to be selected. |
The function is intended to be used in gridded data, but should work on sites irregularly scattered in the xy-space.
A matrix-like object in which the first and second columns are the x and y coordinates. The remaining columns includes species (or attributes) observed in the selected cells.
Adriano Sanches Melo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | x<-rep(1:5,each=5)
y<-rep(1:5,5)
spp<-matrix(1:100,25,4)
colnames(spp)<-c("sp1","sp2","sp3","sp4")
xyspp<-cbind(x,y,spp)
resu<-select.window(xf=3, yf=3, radius=1.1, xydata=xyspp)
resu
plot(x,y) # maintain the plot window open.
points(resu[,1:2],col=2,cex=2 ) # cells of the selected window in red.
#A reduced number of cells will be selected for focal cells located in margins.
resu<-select.window(xf=5, yf=5, radius=1.1, xydata=xyspp)
plot(x,y) # maintain the plot window open.
points(resu[,1:2],col=2,cex=2 ) # cells of the selected window in red.
# Unrecorded species in the selected window are removed from resulting dataframe (or matrix):
spp<-matrix(rep(0:1,each=50),25,4)
colnames(spp)<-c("sp1","sp2","sp3","sp4")
xyspp<-cbind(x,y,spp)
select.window(xf=3, yf=3, radius=1.1, xydata=xyspp)
|
Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.4-4
Loading required package: ape
Loading required package: picante
Loading required package: nlme
x y sp1 sp2 sp3 sp4
[1,] 3 3 13 38 63 88
[2,] 2 2 7 32 57 82
[3,] 2 3 8 33 58 83
[4,] 2 4 9 34 59 84
[5,] 3 2 12 37 62 87
[6,] 3 4 14 39 64 89
[7,] 4 2 17 42 67 92
[8,] 4 3 18 43 68 93
[9,] 4 4 19 44 69 94
x y sp3 sp4
[1,] 3 3 1 1
[2,] 2 2 1 1
[3,] 2 3 1 1
[4,] 2 4 1 1
[5,] 3 2 1 1
[6,] 3 4 1 1
[7,] 4 2 1 1
[8,] 4 3 1 1
[9,] 4 4 1 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.