序列中的 linearK 错误。 default() 不能为 NA, NaN
linearK error in seq. default() cannot be NA, NaN
我正在尝试从 CRC spatstat 书中(第 17 章)学习 linearK 对一个小 linnet 对象的估计,当我使用 linearK 函数时,spatstat 抛出错误。我已经在下面的 r 代码的注释中记录了这个过程。错误如下。
Error in seq.default(from = 0, to = right, length.out = npos + 1L) : 'to' cannot be NA, NaN or infinite
我不知道如何解决这个问题。我正在关注这个过程:
# I have data of points for each data of the week
# d1 is district 1 of the city.
# I did the step below otherwise it was giving me tbl class
d1_data=lapply(split(d1, d1$openDatefactor),as.data.frame)
# I previously create a linnet and divided it into districts of the city
d1_linnet = districts_linnet[["d1"]]
# I create point pattern for each day
d1_ppp = lapply(d1_data, function(x) as.ppp(x, W=Window(d1_linnet)))
plot(d1_ppp[[1]], which.marks="type")
# I am then converting the point pattern to a point pattern on linear network
d1_lpp <- as.lpp(d1_ppp[[1]], L=d1_linnet, W=Window(d1_linnet))
d1_lpp
Point pattern on linear network
3 points
15 columns of marks: ‘status’, ‘number_of_’, ‘zip’, ‘ward’,
‘police_dis’, ‘community_’, ‘type’, ‘days’, ‘NAME’,
‘DISTRICT’, ‘openDatefactor’, ‘OpenDate’, ‘coseDatefactor’,
‘closeDate’ and ‘instance’
Linear network with 4286 vertices and 6183 lines
Enclosing window: polygonal boundary
enclosing rectangle: [441140.9, 448217.7] x [4640080, 4652557] units
# the errors start from plotting this lpp object
plot(d1_lpp)
"show.all" is not a graphical parameter
Show Traceback
Error in plot.window(...) : need finite 'xlim' values
coords(d1_lpp)
x y seg tp
441649.2 4649853 5426 0.5774863
445716.9 4648692 5250 0.5435492
444724.6 4646320 677 0.9189631
3 rows
然后,我在 linearK(d1_lpp)
上也出现错误
Error in seq.default(from = 0, to = right, length.out = npos + 1L) : 'to' cannot be NA, NaN or infinite
我感觉 lpp 对象有问题,但我发现很难解释错误以及如何解决它们。有人可以指导我吗?
谢谢
我可以确认在 plot.lpp
中尝试在线性网络上绘制标记点模式时存在错误。这有望很快得到解决。您可以使用
绘制未标记的点模式
plot(unmark(d1_lpp))
我无法重现 linearK
的问题。你 运行 spatstat
是哪个版本?在我笔记本电脑 spatstat_1.51-0.073
的开发版本中,一切正常。此代码最近有更改,因此很可能会通过更新到开发版本来解决这个问题(参见 https://github.com/spatstat/spatstat)。
我正在尝试从 CRC spatstat 书中(第 17 章)学习 linearK 对一个小 linnet 对象的估计,当我使用 linearK 函数时,spatstat 抛出错误。我已经在下面的 r 代码的注释中记录了这个过程。错误如下。
Error in seq.default(from = 0, to = right, length.out = npos + 1L) : 'to' cannot be NA, NaN or infinite
我不知道如何解决这个问题。我正在关注这个过程:
# I have data of points for each data of the week
# d1 is district 1 of the city.
# I did the step below otherwise it was giving me tbl class
d1_data=lapply(split(d1, d1$openDatefactor),as.data.frame)
# I previously create a linnet and divided it into districts of the city
d1_linnet = districts_linnet[["d1"]]
# I create point pattern for each day
d1_ppp = lapply(d1_data, function(x) as.ppp(x, W=Window(d1_linnet)))
plot(d1_ppp[[1]], which.marks="type")
# I am then converting the point pattern to a point pattern on linear network
d1_lpp <- as.lpp(d1_ppp[[1]], L=d1_linnet, W=Window(d1_linnet))
d1_lpp
Point pattern on linear network
3 points
15 columns of marks: ‘status’, ‘number_of_’, ‘zip’, ‘ward’,
‘police_dis’, ‘community_’, ‘type’, ‘days’, ‘NAME’,
‘DISTRICT’, ‘openDatefactor’, ‘OpenDate’, ‘coseDatefactor’,
‘closeDate’ and ‘instance’
Linear network with 4286 vertices and 6183 lines
Enclosing window: polygonal boundary
enclosing rectangle: [441140.9, 448217.7] x [4640080, 4652557] units
# the errors start from plotting this lpp object
plot(d1_lpp)
"show.all" is not a graphical parameter
Show Traceback
Error in plot.window(...) : need finite 'xlim' values
coords(d1_lpp)
x y seg tp
441649.2 4649853 5426 0.5774863
445716.9 4648692 5250 0.5435492
444724.6 4646320 677 0.9189631
3 rows
然后,我在 linearK(d1_lpp)
Error in seq.default(from = 0, to = right, length.out = npos + 1L) : 'to' cannot be NA, NaN or infinite
我感觉 lpp 对象有问题,但我发现很难解释错误以及如何解决它们。有人可以指导我吗?
谢谢
我可以确认在 plot.lpp
中尝试在线性网络上绘制标记点模式时存在错误。这有望很快得到解决。您可以使用
plot(unmark(d1_lpp))
我无法重现 linearK
的问题。你 运行 spatstat
是哪个版本?在我笔记本电脑 spatstat_1.51-0.073
的开发版本中,一切正常。此代码最近有更改,因此很可能会通过更新到开发版本来解决这个问题(参见 https://github.com/spatstat/spatstat)。