[英]R: Weird behaviour consistent with R specification?
I observe the following, and seemingly inconsistent, behaviour when working with large lists with named fields: 在处理具有命名字段的大型列表时,我观察到以下现象,并且似乎不一致:
> L[[regionID]][203]
$`112175100`
[1] 0
> L[[regionID]][["112175100"]]
[1] 93.98552
and also 并且
> Reduce("+", L[[regionID]])
[1] 434005.8
> S <- 0
> for(n in names(L[[regionID]]))
+ {
+ S <- S + L[[regionID]][[n]]
+ }
> S
[1] 458813.5
Can anyone tell me whether the observed output is consistent with the language specification? 谁能告诉我观察到的输出是否与语言规范一致?
you might have multiple elements with the same name, 您可能有多个具有相同名称的元素,
L <- list()
regionID <- 1
L[[regionID]] <- list("112175100" = 0, "112175100" = 93.98552)
L[[regionID]][2]
L[[regionID]][["112175100"]]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.