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

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

[复制链接]
发表于 2012-9-30 02:36:42 | 显示全部楼层 |阅读模式
eightneighbours(simecol)
eightneighbours()所属R语言包:simecol

                                        Count Number of Neighbours in a Rectangular Cellular Grid.
                                         算号街坊的矩形蜂窝网格。

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

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

This function returns the sum of the eight neibours of a cell within a matrix. It can be used to simulate simple cellular automata, e.g. Conway's Game of Life.
此函数返回一个矩阵内的单元格的八个neibours总和。它可以被用来模拟简单的元胞自动机,例如:康威的生命游戏。


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


  eightneighbours(x)
  eightneighbors(x)



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

参数:x
The cellular grid, which typically contains integer values of zero (dead cell) or one (living cell).
蜂窝网格,它通常包含零(死单元)或1(活单元)的整数值。


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

A matrix with the same structure as x, but with the sum of the neighbouring cells of each cell.
具有相同的结构的矩阵作为x,但与各小区的相邻小区的总和。


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

seedfill, neighbours, conway
seedfill,neighbours,conway


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


n <- 80; m <- 80
x <- matrix(rep(0, m*n), nrow = n)
x[round(runif(1500, 1, m*n))] <- 1
## uncomment this for another figure[#注解为一个数字]
#x[40, 20:60] &lt;- 1[[40 20:60] < -  1]

image(x, col=c("wheat", "grey", "red"))
x2 <- x
for (i in 2:10){
  nb <- eightneighbours(x)

  ## survive with 2 or 3 neighbours[#求生存,以2个或3个邻居]
  xsurv <- ifelse(x > 0 &amp; (nb == 2 | nb ==3), 1, 0)

  ## generate for empty cells with 3 neigbours[#为空3 neigbours单元产生]
  xgen <- ifelse(x == 0 &amp; nb == 3, 1, 0)

  x  <- ((xgen + xsurv)>0)
  x2 <- ifelse(x2>1, 1, x2)
  x2 <- ifelse(x>0, 2, x2)

  image(x2, col=c("wheat", "grey", "red"), add=TRUE)
}

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-23 22:23 , Processed in 0.026192 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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