- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 spplot 绘制德国的热图,我有来自 GADM German shape file 的形状文件1级
http://biogeo.ucdavis.edu/data/gadm2.8/rds/DEU_adm1.rds
我能够制作热图,但我认为 map 绘制错误,例如在我的数据中“不来梅”的值为 0 但“萨克森-安哈尔特
"被绘制为具有 0 个值的白色,是否与 .rds 文件中的映射有关?
这是我的代码
library(sp)
library(latticeExtra)
### load the German federal state polygons
my.data <- readRDS("DEU_adm1.rds")
sample <- read.csv(file.choose())
final <- merge(x =my.data@data, y = sample, by = "ID_1", all.y = TRUE)
my.data@data <- data.frame(my.data@data, sample[match(my.data@data[,"ID_1"], sample[,"ID_1"]),])
### German language hick-ups need to be resolved
enamessp <- gsub("?", "ue", my.data@data$NAME_1)
my.data@data$NAME_1 <- enamessp
### insert the newly created clicksvariable into the spatial data frame
my.data$clicks <- sample$clicks
clrs <- c('#F4F1A2',
'#F4F1A2',
'#E6EAA2',
'#E6EAA2',
'#CFE3A2',
'#CFE3A2',
'#9AD0A3',
'#9AD0A3',
'#7FC9A4',
'#7FC9A4',
'#32B9A3',
'#32B9A3',
'#00A7A2',
'#00667E',
'#00667E',
'#1D4F73'
)
spplot(my.data, zcol = "clicks", main = "Region Distribution",
col.regions = clrs,at=sort(sample$clicks))
structure(list(ID_1 = c(7L, 4L, 5L, 14L, 12L, 15L, 11L, 13L,
2L, 3L, 16L, 6L, 10L, 9L, 8L, 1L), clicks = c(19L, 4L, 0L, 12L,
4L, 3L, 8L, 5L, 41L, 12L, 4L, 11L, 59L, 19L, 4L, 25L)), .Names = c("ID_1",
"clicks"), class = "data.frame", row.names = c(NA, -16L))
最佳答案
spplot
效果很奇怪,我先走了几条死胡同。但基本上你很接近,那 at=sort(sample$clicks)
搞砸了,你只需要摆脱它。
library(sp)
### load the German geo map polygons
my.data <- readRDS("DEU_adm1.rds")
### sample "clicks" data with German state coded as ID_1
sample <- data.frame(
ID_1 = c( 7, 4, 5, 14, 12, 15, 11, 13, 2, 3, 16, 6, 10, 9, 8, 1L),
clicks = c(19, 4, 0, 12, 4, 3, 8, 5, 41, 12, 4, 11, 59, 19, 4, 25L))
### Merge sample data with geo map data
final <- merge(x =my.data@data, y = sample, by = "ID_1", all.y = TRUE)
my.data@data <- data.frame(my.data@data,
sample[match(my.data@data[,"ID_1"],
sample[,"ID_1"]),])
### German language hick-ups need to be resolved
enamessp <- gsub("?", "ue", my.data@data$NAME_1)
my.data@data$NAME_1 <- enamessp
# print out states and clicks (sorted high to low) for verification
final[ order(-final$clicks),c("ID_1","NAME_1","HASC_1","clicks") ]
### insert the newly created clicksvariable into the spatial data frame
my.data$clicks <- final$clicks
clrs <- c('#F4F1A2','#F4F1A2','#E6EAA2','#E6EAA2',
'#CFE3A2','#CFE3A2','#9AD0A3','#9AD0A3',
'#7FC9A4','#7FC9A4','#32B9A3','#32B9A3',
'#00A7A2','#00667E','#00667E','#1D4F73')
spplot(my.data, zcol = "clicks", main = "Clicks Region Distribution", col.regions = clrs)
> print(sample[ order(-sample$clicks), ])
ID_1 clicks land hasc
13 10 59 Saxony-Anhalt DE.ST
9 2 41 Lower Saxony DE.NI
16 1 25 Thuringia DE.TH
1 7 19 DE.BW
14 9 19 Saxony DE.SN
4 14 12 DE.BR
10 3 12 North Rhine-Westphalia DE.NW
12 6 11 DE.SL
7 11 8 Hesse DE.HE
8 13 5 Mecklenburg-West Pomerania DE.MV
2 4 4 Bavaria DE.BY
5 12 4 <Null> DE.HB
11 16 4 Rhineland-Palatinate DE.RP
15 8 4 DE.SH
6 15 3 DE.HH
3 5 0 DE.BE
关于r - 使用 spplot 的德国热图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34691798/
场景: 我正在开发一个iOS应用,应该将其上传到世界各地的所有应用商店中。 该应用程序应支持2种语言,德语和英语。德国使用德语,世界其他地区使用英语。 我做了什么: 当我开始开发该应用程序时,我在In
我想在 iPhone 应用程序中使用 TradeDoubler(欧洲)和 LinkShare(美国、加拿大)并链接到应用程序商店。我已经知道我总是会被带到正确的商店。但是每个国家/项目的附属链接都是不
我的 Angular 应用程序需要以不同格式显示货币,例如:$、£、2.105,10€ - + 之后的欧元符号不同的分隔符 - 这可以通过包含 i18n angular-locale_de-de.js
背景 我正在使用 NLog 2.0.1 版,我相信这是最新版本,来自 .Net 4.0 控制台应用程序(使用 Visual Studio 2012 编写)。 应用程序很简单: namespace NL
我在我的 asp.net 应用程序中使用德语 UI Culture。我正在根据下拉列表中选择的语言更改我的应用程序的 UI 区域性,在下拉列表中选择的索引更改我正在使用此代码 Thread.Curre
我是一名优秀的程序员,十分优秀!