gapply(sna)
gapply()所属R语言包:sna
Apply Functions Over Vertex Neighborhoods
过顶点的社区应用功能
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Returns a vector or array or list of values obtained by applying a function to vertex neighborhoods of a given order.
返回一个向量,或应用一个函数到顶点的社区一个给定的顺序而获得的值的数组或列表。
用法----------Usage----------
gapply(X, MARGIN, STATS, FUN, ..., mode = "digraph", diag = FALSE,
distance = 1, thresh = 0, simplify = TRUE)
参数----------Arguments----------
参数:X
one or more input graphs.
一个或多个输入图表。
参数:MARGIN
a vector giving the “margin” of X to be used in calculating neighborhoods. 1 indicates rows (out-neighbors), 2 indicates columns (in-neighbors), and c(1,2) indicates rows and columns (total neighborhood).
一个向量,给人以“保证金”的X可用于计算的邻里。 1表示行(满分邻居),2表示的列(在邻居),和C(1,2)表示的行和列(总街道)。
参数:STATS
the vector or matrix of vertex statistics to be used.
要使用的向量或矩阵的顶点统计。
参数:FUN
the function to be applied. In the case of operators, the function name must be quoted.
该函数被应用。在运营商的情况下,函数名必须加引号。
参数:...
additional arguments to FUN.
附加参数到FUN。
参数:mode
"graph" if X is a simple graph, else "digraph".
"graph"如果X是一个简单的图形,否则"digraph"。
参数:diag
boolean; are the diagonals of X meaningful?
布尔值是的对角线X有意义的吗?
参数:distance
the maximum geodesic distance at which neighborhoods are to be taken. 1 signifies first-order neighborhoods, 2 signifies second-order neighborhoods, etc.
最大的测地距离应采取哪些社区是。 1表示一阶的街区,2表示二阶街区等
参数:thresh
the threshold to be used in dichotomizing X.
该阈值被用于在二分法X。
参数:simplify
boolean; should we attempt to coerce output to a vector if possible?
布尔值;强制输出到一个向量如果可能的话,我们应该尝试吗?
Details
详细信息----------Details----------
For each vertex in X, gapply first identifies all members of the relevant neighborhood (as determined by MARGIN and distance) and pulls the rows of STATS associated with each. FUN is then applied to this collection of values. This provides a very quick and easy way to answer questions like:
中每个顶点X,gapply首先确定相关的社区的所有成员(MARGIN和distance)和拉行的STATS相关的决定与每个。 FUN,然后应用到这个集合中的值。这提供了一个非常快速和简单的方法来回答这样的问题:
How many persons are in each ego's 3rd-order neighborhood?
每一个自我的三阶附近有多少人?
What fraction of each ego's alters are female?
每一个自我的改变有多大比例的女性吗?
What is the mean income for each ego's trading partners?
平均收入为每一个自我的贸易伙伴是什么?
etc.
等等
With clever use of FUN and STATS, a wide range of functionality can be obtained.
巧妙地利用了FUN和STATS,广泛的功能,可以得到。
值----------Value----------
The result of the iterated application of FUN to each vertex neighborhood's STATS.
FUN各顶点附近的STATS迭代应用的结果。
(作者)----------Author(s)----------
Carter T. Butts <a href="mailto:buttsc@uci.edu">buttsc@uci.edu</a>
参见----------See Also----------
apply, sapply
apply,sapply
实例----------Examples----------
#Generate a random graph[生成一个随机图]
g<-rgraph(6)
#Calculate the degree of g using gapply[度计算的G gapply]
all(gapply(g,1,rep(1,6),sum)==degree(g,cmode="outdegree"))
all(gapply(g,2,rep(1,6),sum)==degree(g,cmode="indegree"))
all(gapply(g,c(1,2),rep(1,6),sum)==degree(symmetrize(g),cmode="freeman")/2)
#Find first and second order neighborhood means on some variable[找到第一个和第二顺序的社区,对一些变量]
gapply(g,c(1,2),1:6,mean)
gapply(g,c(1,2),1:6,mean,distance=2)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|