r - 向 tm_object 添加中断的问题
问题描述
我在向 tm_map 添加固定中断时遇到了麻烦。我在不同的数据集上尝试了与该论坛上另一个主题相同的代码(自定义如何打印 R tmap 图例值),但原理是相同的。我使用了论坛中的示例,因为在 Map1 行的休息部分中添加所有值也不起作用。然而,这两种情况都给了我错误:
Error in .subset2(x, i, exact = exact) : no such index at level 1
谁能解释我这个错误的确切含义以及如何克服它?
代码
mybreaks1 = c(0, 5, 15, 25, 35, 70)
mybreaks2 = c()
for (i in 1:length(mybreaks1)-1){
print(i)
if (i == 1){
mybreaks2[i] <- paste0(mybreaks1[i], " - ", mybreaks1[i+1])
}
if (i >1){
mybreaks2[i] <- paste0(prettyNum(mybreaks1[i]+1, big.mark = " "), " - ", prettyNum(mybreaks1[i+1], big.mark = " "))
}
}
Map1 = tm_shape(Week1_PlasticMap) + tm_fill(col = "total.per.segment" , breaks = mybreaks1, labels = mybreaks2, style = "fixed", convert2density = TRUE, area = Week1_PlasticMap$area, title = "Plastics (m^-2)", interactive = TRUE) + tm_borders(col = "darkslategrey") + tm_layout(main.title = "Week 1", legend.outside = TRUE, attr.outside= TRUE, attr.outside.position=c("right", "bottom"), legend.width = 0.2, legend.height = 0.3)```
The dataframe Week1_Plastic can be downloaded via the link below, because the dimensions are to large to upload in this question.
https://www.transfernow.net/7il18A012021
解决方案
我自己修好了!原来我的数据表有问题。
推荐阅读
- spring - 服务端启动后如何初始化dataSource、transactionManager配置bean?
- angular - 无法在 Angular 的 GET 请求中显示在 Chrome [object Object] 中
- javascript - 警告后我的计算器没有响应
- c# - 如何将 xpath 声明为字符串变量?C#
- python - Python 库是否特定于操作系统
- html - 在弹出窗口上禁用滚动条
- dialogflow-es - Dialogflow 匹配错误
- azure-devops - Azure DevOps - 组织项目和存储库
- node.js - 当“selfHandleResponse”为真时,如何传递代理响应?
- c# - c#获取对象的自定义事件列表