代码之家  ›  专栏  ›  技术社区  ›  compbiostats

R默认为一个值。为什么不是天花板()或圆形()?

r
  •  0
  • compbiostats  · 技术社区  · 5 年前

    x <- 50.8 # number of rows
    y <- 100 # number of columns
    
    res <- array(dim = c(x, y, 1))
    dim(res) # dimensions of res = 50 100 1
    

    显然,x必须是一个整数。

    在我看来,地板()没有什么特别之处。

    1 回复  |  直到 5 年前
        1
  •  1
  •   Maurits Evers    5 年前

    太长,读不下去了 这个 dim 论据 array 将数字强制为整数。


    ?array

    dim:要创建的数组的dim属性,即 长度为一个或多个,给出每个维度的最大索引。

    所以 c(x, y, 1) integer 大堆 asInteger (见 lines 101 and 109 of the source code ).