找回密码
 注册
查看: 371|回复: 0

R语言 spatstat包 applynbd()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 13:09:33 | 显示全部楼层 |阅读模式
applynbd(spatstat)
applynbd()所属R语言包:spatstat

                                        Apply Function to Every Neighbourhood in a Point Pattern
                                         功能点模式中的每一个邻里

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Visit each point in a point pattern, find the neighbouring points, and apply a given function to them.
访问每一个点一个点的图案,找到相邻点,和他们应用的功能。


用法----------Usage----------


   applynbd(X, FUN, N, R, criterion, exclude=FALSE, ...)



参数----------Arguments----------

参数:X
Point pattern.  An object of class "ppp", or data which can be converted into  this format by as.ppp.  
点模式。一个目的类"ppp",或数据,可被转化成这种格式as.ppp。


参数:FUN
Function to be applied to each neighbourhood. The arguments of FUN are described under Details.  
功能被应用到每一个邻里。 FUN的参数描述下详细信息。


参数:N
Integer. If this argument is present, the neighbourhood of a point of X is defined to consist of the N points of X which are closest to it. This argument is incompatible with R and criterion.  
整数。如果这种说法是存在的,附近的一个点X定义包括N点X这是最接近它的。这种说法是不符合R和criterion。


参数:R
Nonnegative numeric value. If this argument is present, the neighbourhood of a point of X is defined to consist of all points of X which lie within a distance R of it. This argument is incompatible with N and criterion.  
非负数值。如果这种说法是存在的,附近的点X定义包括所有点X范围内的距离R。这种说法是不符合N和criterion。


参数:criterion
Function. If this argument is present,  the neighbourhood of a point of X is determined by evaluating this function. See under Details. This argument is incompatible with N and R.  
功能。如果这种说法是存在的,附近的点X确定,评价此功能。请参阅“详细信息”下。这种说法是不符合N和R。


参数:exclude
Logical. If TRUE then the point currently being visited is excluded from its own neighbourhood.  
逻辑。如果TRUE然后点被排除在其周边区域目前被访问。


参数:...
extra arguments passed to the function FUN. They must be given in the form name=value.  
额外的参数传递给函数FUN。必须给予他们的形式name=value。


Details

详细信息----------Details----------

This is an analogue of apply for point patterns. It visits each point in the point pattern X, determines which points of X are “neighbours” of the current point, applies the function FUN to this neighbourhood, and collects the values returned by FUN.
这是一个模拟的apply点模式。访问每个点的点模式X,确定哪些点X是当前点的“邻居”,适用的功能FUN:这附近,并收集返回的值FUN。

The definition of “neighbours” depends on the arguments N, R and criterion, exactly one of which must be given. Also the argument exclude determines whether the current point is excluded from its own neighbourhood.
N,R和criterion,正是其中之一,必须给予的“邻居”的定义取决于具体的参数。此外,参数exclude确定当前点是否被排除从它自己的附近。

If N is given, then the neighbours of the current point are the N points of X which are closest to the current point (including the current point itself unless exclude=TRUE).
如果N给定的,那么当前点的邻居是N分X这是最接近当前点(包括目前的点位本身,除非exclude=TRUE) 。

If R is given, then the neighbourhood of the current point consists of all points of X which lie closer than a distance R from the current point.
R如果是给定的,那么目前的点位附近的X更近的距离R:从目前的点位于包括所有的点。

If criterion is given, then it must be a function with two arguments dist and drank which will be vectors of equal length. The interpretation is that dist[i] will be the distance of a point from the current point, and drank[i] will be the rank of that distance (the three points closest to the current point will have rank 1, 2 and 3). This function must return a logical vector of the same length as dist and drank whose i-th entry is TRUE if the corresponding point should be included in the neighbourhood. See the examples below.
criterion如果是给定的,那么它必须是一个函数有两个参数dist和drank这将是向量的长度相等。的解释是dist[i]会是一个点的距离,从目前来看,和drank[i]将是排名的距离(三个点到当前点最近的秩为1,2, 3)。此函数必须返回一个逻辑向量的长度相同dist和drank的个条目是iTRUE,如果对应点应包括在附近。请参见下面的例子。

When applynbd is executed,  each point of X is visited, and the following happens for each point:
当applynbd执行,每个X点访问,并发生以下各点:

the neighbourhood of the current point is determined according to the chosen rule, and stored as a point pattern Y;
目前的点位附近,根据所选择的规则,并存储为一个点模式Y;

the function FUN is called as:
的功能FUN被称为:

FUN(Y=Y, current=current, dists=dists, dranks=dranks, ...)
FUN(Y=Y, current=current, dists=dists, dranks=dranks, ...)

where current is the location of the current point (in a format explained below), dists is a vector of distances from the current point to each of the points in Y,  dranks is a vector of the ranks of these distances with respect to the full point pattern X, and ... are the arguments passed from the call to applynbd;
其中current是的当前点的位置(在下面解释的格式),dists从当前点的距离是一个向量的每一个点在Y,<X >的行列,这些距离是一个向量的点模式dranks和X是从调用的参数传递到...;

The result of the call to FUN is stored.
调用FUN的结果被存储。

The results of each call to FUN are collected and returned according to the usual rules for apply and its relatives. See the Value section of this help file.
每个调用的结果FUN收集,并根据返回apply及其亲属的一般规则。这个帮助文件,请参阅值部分。

The format of the argument current is as follows. If X is an unmarked point pattern, then current is a vector of length 2 containing the coordinates of the current point. If X is marked, then current is a point pattern containing exactly one point, so that current$x is its x-coordinate and current$marks is its mark value. In either case, the coordinates of the current point can be referred to as current$x and current$y.
格式的参数current如下。如果X是一个没有标记的点模式,那么current是一个矢量的长度为2,包含当前点的坐标。 X如果标记,然后current是包含一个点一个点的模式,使current$x是x坐标和current$marks是它的标记值。在任一种情况下,当前点的坐标可以被称为current$x和current$y。

Note that FUN will be called exactly as described above, with each argument named explicitly. Care is required when writing the function FUN to ensure that the arguments will match up. See the Examples.
请注意,FUN将称为精确如上所述,每个命名参数明确。护理时,需要编写的功能FUN,以确保该参数将匹配。请参阅范例。

See markstat for a common use of this function.
见markstat为了一个共同的使用此功能。

To simply tabulate the marks in every R-neighbourhood, use marktable.
只是简单的制表在每一个R邻域的标记,使用marktable。


值----------Value----------

Similar to the result of apply. If each call to FUN returns a single numeric value, the result is a vector of dimension X$n, the number of points in X. If each call to FUN returns a vector of the same length m, then the result is a matrix of dimensions c(m,n); note the transposition of the indices, as usual for the family of apply functions. If the calls to FUN return vectors of different lengths, the result is a list of length X$n.
类似apply的结果。如果每次调用FUN返回一个单一的数值,结果是一个向量的维X$n,点的数量在X。如果每次调用FUN返回一个向量的长度相同m,那么结果是一个矩阵的尺寸c(m,n);注意换位的指标,像往常一样为家人 apply函数。如果调用FUN返回向量不同长度,结果是一个列表的长度X$n。


(作者)----------Author(s)----------


Adrian Baddeley
<a href="mailto:Adrian.Baddeley@csiro.au">Adrian.Baddeley@csiro.au</a>
<a href="http://www.maths.uwa.edu.au/~adrian/">http://www.maths.uwa.edu.au/~adrian/</a>
and Rolf Turner
<a href="mailto:r.turner@auckland.ac.nz">r.turner@auckland.ac.nz</a>




参见----------See Also----------

ppp.object, apply, markstat, marktable
ppp.object,apply,markstat,marktable


实例----------Examples----------


  data(redwood)

  # count the number of points within radius 0.2 of each point of X[每个点的X半径0.2内的点的数量计数]
  nneighbours <- applynbd(redwood, R=0.2, function(Y, ...){Y$n-1})
  # equivalent to:[等效于:]
  nneighbours <- applynbd(redwood, R=0.2, function(Y, ...){Y$n}, exclude=TRUE)

  # compute the distance to the second nearest neighbour of each point[计算第二近邻的各点的距离]
  secondnndist <- applynbd(redwood, N = 2,
                           function(dists, ...){max(dists)},
                           exclude=TRUE)

  # marked point pattern[标记点模式]
  data(longleaf)
  
  # compute the median of the marks of all neighbours of a point[计算中位数的所有邻居的标志]
  # (see also 'markstat')[(见“markstat)]
  dbh.med <- applynbd(longleaf, R=90, exclude=TRUE,
                 function(Y, ...) { median(Y$marks)})


  # ANIMATION explaining the definition of the K function[动画解释K函数的定义的]
  # (arguments `fullpicture' and 'rad' are passed to FUN)[(的参数fullpicture“和”RAD“传递给FUN)]

  ## Not run: [#不运行:]
  showoffK <- function(Y, current, dists, dranks, fullpicture,rad) {
        plot(fullpicture, main="")
        points(Y, cex=2)
        u <- current
        points(u$x,u$y,pch="+",cex=3)
        theta <- seq(0,2*pi,length=100)
        polygon(u$x+ rad * cos(theta),u$y+rad*sin(theta))
        text(u$x+rad/3,u$y+rad/2,Y$n,cex=3)
        Sys.sleep(if(runif(1) < 0.1) 1.5 else 0.3)
        return(Y$n - 1)
  }
  applynbd(redwood, R=0.2, showoffK, fullpicture=redwood, rad=0.2, exclude=TRUE)

  # animation explaining the definition of the G function[动画的定义说明的G功能]

  showoffG <- function(Y, current, dists, dranks, fullpicture) {
        plot(fullpicture, main="")
        points(Y, cex=2)
        u <- current
        points(u[1],u[2],pch="+",cex=3)
        v <- c(Y$x[1],Y$y[1])
        segments(u[1],u[2],v[1],v[2],lwd=2)
        w <- (u + v)/2
        nnd <- dists[1]
        text(w[1],w[2],round(nnd,3),cex=2)
        Sys.sleep(if(runif(1) < 0.1) 1.5 else 0.3)
        return(nnd)
  }

  data(cells)
  applynbd(cells, N=1, showoffG, exclude=TRUE, fullpicture=cells)
  
## End(Not run)[#(不执行)]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-6-13 18:32 , Processed in 0.024740 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表