简体   繁体   English

使用RSCript将数字/数据点绘制到世界地图上

[英]Plot numbers / data points onto a World Map using RSCript

Using RSCript and the rworldmap package. 使用RSCript和rworldmap包。 I would like to create an output to be able to show the no of documents published within each company. 我想创建一个输出,以便能够显示每个公司内发布的文档数量。 Roughly based around mapPies but instead of using pie charts to be able to just display the data on the chart. 大致基于mapPies,但不是使用饼图就能仅在图表上显示数据。

I have my own txt file that has 3 columns - ISO3V10, Country and No of Documents. 我有自己的txt文件,该文件具有3列-ISO3V10,国家/地区和文档编号。

ISO3V10 Country              No of Documents
CAN     Canada               30
CHN     China                20
RUS     Russia               10
GBR     United Kingdom       38
USA     United States        50

For United States the number 50 would appear and United Kingdom 38 etc... On the image shown below!!!! 对于美国,数字50会出现,英国38等等。在下面显示的图像上!!!!

I have images of I would like it to look like but I cant post any images, happy to send if need clarification 我有自己想要的图片,但我无法发布任何图片,如果需要澄清,很高兴发送

I have created a world map using RSCript and rworldmap so to apply code that does that would be brilliant. 我已经使用RSCript和rworldmap创建了一个世界地图,因此可以应用出色的代码。

The code I used to generate the world map is as follows: 我用来生成世界地图的代码如下:

library(rworldmap) 
require(rworldmap)
myData2 <- read.delim(file="C:\\Documents\\Projects\\RScriptAnalysis\\noofpublications2.txt", header = TRUE, sep = "\t")
names(myData2)
sPDF2 <- joinCountryData2Map(myData2, joinCode = "ISO3", nameJoinColumn = "ISO3V10")
par(mai=c(0,0,0.2,0),xaxs="i",yaxs="i")
mapParams <- mapCountryData(sPDF2, nameColumnToPlot="No.of.Documents", catMethod = "categorical", addLegend=FALSE)
do.call( addMapLegend, c(mapParams, legendWidth=0.5, legendMar = 2))

If this possible to do using RSCript and rworldmap can you write the code or adapt my code that allows me to do this? 如果可以使用RSCript和rworldmap做到这一点,您可以编写代码或改编允许我执行此操作的代码吗?


This is what I would like to be able to do! 这就是我想要做的!

Where can I find out the longitude and latitude as this would be better. 在哪里可以找到经度和纬度,因为这样会更好。

As the output I would like is the number of documents displayed on the map for each country! 作为输出,我想要的是每个国家在地图上显示的文档数量!

Would you be able to edit my file and code above in the original question to show me how to do this? 您能否在上面的原始问题中编辑我的文件和代码,以向我展示如何执行此操作?

Is it possible? 可能吗? This is R. 这是R。

require(fortunes)
fortune("Yoda")

You may need to be more specific about exactly where you want these numbers since the merger gets you more than 5 areas: 您可能需要更具体地确定这些数字的确切位置,因为合并使您获得了5个以上的领域:

str(sPDF2@data[which(sPDF2@data$ISO3V10 =="GBR"),])
'data.frame':   1 obs. of  15 variables:
 $ FIPS        : Factor w/ 244 levels "","AC","AE","AF",..: 224
 $ ISO2        : Factor w/ 246 levels "AD","AE","AF",..: 76
 $ ISO3        : Factor w/ 246 levels "ABW","AFG","AGO",..: 79
 $ UN          : int 826
 $ NAME        : Factor w/ 246 levels "Afghanistan",..: 230
 $ AREA        : int 24193
 $ POP2005     : int 60244834
 $ REGION      : int 150
 $ SUBREGION   : int 154
 $ LON         : num -2.9
 $ LAT         : num 54.2
 $ ISO3V10     : Factor w/ 5 levels "CAN","CHN","GBR",..: 3
 $ Country     : Factor w/ 5 levels "Canada","China",..: 4
 $ No_Documents: int 38
 $ ISO3        : Factor w/ 5 levels "CAN","CHN","GBR",..: 3

So why not provide coordinates for the locations where you want these numbers placed and and edit your input file to reflect that choice. 因此,为什么不为要放置这些数字的位置提供坐标,并编辑输入文件以反映该选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM