Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的Choroplet映射_R_Dictionary_Visualization - Fatal编程技术网

R中的Choroplet映射

R中的Choroplet映射,r,dictionary,visualization,R,Dictionary,Visualization,我试图在科索沃地图上绘制列检测功能下的值,并且按照中描述的方法,我无法获得一个很好的可视化效果。你能帮我吗? 我不太熟悉R,也不太熟悉地图可视化,但我认为“id”和“NAME_1”之间应该存在问题 install.packages(“光栅”) 安装程序包(“ggplot2”) 安装程序包(“rgeos”) 安装程序包(“maptools”) 安装软件包(“天平”) 图书馆(光栅) states.shp install.packages("raster") install.pa

我试图在科索沃地图上绘制列检测功能下的值,并且按照中描述的方法,我无法获得一个很好的可视化效果。你能帮我吗? 我不太熟悉R,也不太熟悉地图可视化,但我认为“id”和“NAME_1”之间应该存在问题

install.packages(“光栅”)
安装程序包(“ggplot2”)
安装程序包(“rgeos”)
安装程序包(“maptools”)
安装软件包(“天平”)
图书馆(光栅)
states.shp
install.packages("raster")
install.packages("ggplot2")
install.packages("rgeos")
install.packages("maptools")
install.packages("scales")


 library(raster)
 states.shp <- readOGR(file.choose())
  names(states.shp)
  View(states.shp$NAME_1)
  library(rgeos)
  library(maptools)
  library(ggplot2)
  states.shp.f <- fortify(states.shp, region = "NAME_1")
  class(states.shp.f)
  head(states.shp.f)


  library(scales)
  library(ggmap)
  mydata <- read_excel("Perplot.xlsx", sheet = 1)
  mydata

    id          Detection Capability
  1 Pristina    26.95
  2 Pristina    28.45
  3 Pristina    29.95
  4 Pristina    29.95
  5 Urosevac    29.95
  6 Gnijlane    30.79
  7 Prizren     31.45
  8 Pristina    31.45
  9 Urosevac    31.45
  10 Kosovska Mitrovica 32.95
  11 Kosovska Mitrovica 34.79
  12 Gnijlane   35.45
  13 Dakovica   35.45
  14 Urosevac   35.45
  15 Gnijlane   35.45
  16 Gnijlane   35.45


  View(states.shp)
  merge.shp.coef <- merge(states.shp.f, mydata, by = "id")
  head(merge.shp.coef)
  View(merge.shp.coef)
  merge.shp.coef$`Detection Capability` <- 
  as.numeric(merge.shp.coef$`Detection Capability`)

  ggplot() + geom_polygon(data = merge.shp.coef, aes(x = long, y = 
  lat, group = group, 
                                               fill = Detection 
   Capability), color = "black", size = 0.25)