嗨。我使用"rworldmap“软件包作为我的数据。一切执行良好,唯一的问题是与kniting的html格式。html输出不显示地图。我在html输出中有其他图形。他们绘制的图(地图)--那不是世界地图。 注意: 我需要上传我的数据作为html文件。 由于我的数据,我正在使用库(Rworldmap)。
我不知道为什么针织(html)不显示在我的文件中的地图。有什么建议吗?
html文件的格式:
---
output:
html_document:
toc: true
code_folding: show
toc_float:
collapsed: false
smooth_scroll: true
number_sections: true
pdf_document: default
word_document: default
---开始:
library(rworldmap)
str(data)
Country: chr "ALBANIA" "ALBANIA" "ALBANIA" "ALBANIA"
var1: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1
var2: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1
var3: Factor w/ 2 levels "0","1": 1 2 2 2 2 2 2 2 2 2 表:
Country var1 var2 var3 n Perc
ALBANIA 1 1 1 1 0.075
TURKEY 1 1 1 18 1.35
GERMANY 1 1 0 3 0.22
...N是频率
rworldmap代码:
dev.new(width=20, height=20)
summary_probn<-count(data, Country,
var1,var3,
var2)
diss_c<- subset(summary_probn, var1 =="1")
#table<-table(diss_c)#frequency
#proptable<- prop.table(table(diss_c))#Cumulative frequency
#cbind(table, proptable)
diss_c$Perc <- diss_c$n / sum(diss_c$n) * 100
diss_cc<- subset(diss_c, var1 =="1")
diss_cj <- subset(diss_cc, var2 =="1")数据类似于以下输出:
地图
mapped_data2 <- joinCountryData2Map(diss_cj, joinCode = "NAME",
nameJoinColumn = "Country")
par(mai=c(1,0,0.8,2),xaxs="i",yaxs="i")
mapParams <- mapCountryData(mapped_data2, nameColumnToPlot = "Perc",
catMethod="fixedWidth", addLegend=FALSE, mapTitle="Europe", mapRegion = "europe")
do.call(addMapLegend ,c(mapParams ,legendLabels="all",legendWidth=1,legendIntervals="data", legendMar = 3, labelFontSize = 1))
#do.call( addMapLegend, c(mapParams, legendWidth=1.5, legendMar = 2, legendLabels="all"))
colourPalette <- c('white','green','red','yellow','blue','black')发布于 2018-08-26 20:57:26
我找到了这个问题的答案。我在重标记文件中定义了这个特性:"dev.new(width=20,height=20)“。当我删除它时,"rworldmap输出“出现在html文件中。
https://stackoverflow.com/questions/51874339
复制相似问题