【问题标题】:Unexpected behavior in spatstat hyperframes?spatstat 超帧中的意外行为?
【发布时间】:2014-03-18 10:15:01
【问题描述】:

我正在尝试从包含 owin 对象(或任何与此相关的任何 spatstat 对象)的列表超帧中生成 spatstat hyperframes,但在 do.call 中使用 rbind.hyperframe 命令绑定列表时会遇到意外行为变成更大的hyperframe

library(spatstat)
circles <- list(large = disc(10), medium = disc(5), small = disc(1))

circle.list <- lapply(names(circles), function(k) hyperframe(name = k, circle = circles[[k]]))
circle.list

# [[1]]
# Hyperframe:
#   name circle
# 1 large (owin)

此时列表可以正常工作。 owin 对象分别位于列出的超帧的每个单元格中:

circle.list[[1]]$circle

#window: polygonal boundary
#enclosing rectangle: [-10, 10] x [-10, 10] units  

接下来我使用do.call 命令来rbind 超帧:

circle.hyperframe <- do.call(rbind.hyperframe, circle.list)
circle.hyperframe

# Hyperframe:
#    name circle
# 1  large (list)
# 2 medium (list)
# 3  small (list)

现在圆圈是列表(它们本质上是在 spatstat 中的),但它们似乎都绑定在一起:

names(circle.hyperframe[1,]$circle)
# [1] "type"   "xrange" "yrange" "bdry"   "units"  "type"   "xrange" "yrange" "bdry"  
# [10] "units"  "type"   "xrange" "yrange" "bdry"   "units" 

注意一个单元格的三重名称。

我的代码依赖于列表,我非常希望能够将这些列表绑定到一个更大的hyperframe 中。 有没有办法解决这种行为,即如何在不绑定“圆形”列中的单元格的情况下重新绑定超帧?

【问题讨论】:

    标签: r spatstat


    【解决方案1】:

    我同意这种行为是意外的,我目前不知道解释。您的示例有一个简单的解决方案,但我不确定它在您可能需要它的更一般的设置中是否有用:

    library(spatstat)
    circles <- list(large = disc(10), medium = disc(5), small = disc(1))
    circle.hyperframe <- hyperframe(name=names(circles), circle=circles)
    

    【讨论】:

    • 您的解决方案实际上解决了我遇到的一个特殊问题,尽管我不得不稍微修改一下角度。我没有考虑将列表直接添加为列,因为我一直在思考它如何与 data.frames 一起工作。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-16
    • 2021-06-11
    • 1970-01-01
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    相关资源
    最近更新 更多