前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >你知道经管类的核心期刊都分布在那里吗?

你知道经管类的核心期刊都分布在那里吗?

作者头像
数据小磨坊
发布2018-04-11 16:21:11
7310
发布2018-04-11 16:21:11
举报
文章被收录于专栏:数据小魔方数据小魔方

最近在看文献,看的有些烦躁了,想找点儿熟练练练手,刚好看到百度百科有这个关于经管类核心期刊的汇总表,顺手就抓过来练习练习。

本来百度百度中核心期刊栏目的列表里,关于经济学72中核心期刊的详细地址不全,我申请了编辑字条,编完一直在审核,想想算了,根据百度百科的审核流程和效率,估计不知道要申到猴年马月了,自己搜了确实的地址信息。

以下数数据的爬取、清洗和可视化过程:

library(rvest) library(stringr) library(dplyr) library(ggplot2) library(plyr) library(rjson) library(Cairo) library(Cairo) library(showtext) library(maptools)

表格爬取(这里用revst来爬,效率特别高)

url<-"http://baike.baidu.com/link?url=VRCRtZ-GR4Lv483tBm2d6IQ3mOjTlcc1z80EBBzFwCGAlDT16NvxH_yqshJdSD95_AEEu_Hzg4uE3ok3bDIohkkl9sTwpE9cVJcRP7RpAmVBIeEmwZ4gdXNetbA8lvmU" info<-read_html(url,encoding="UTF-8")%>%html_nodes("table")%>%html_table(header=TRUE,fill=TRUE)

表格的提取过程:

economic<-info[[1]][,-1];names(economic)<-c("Name","Address");economic$Class<-"C" mangement<-info[[2]][,-1];names(mangement)<-c("Name","Address");mangement$Class<-"M"

打开数据编辑器,自己把缺失的地址补全

fix(economic)

剔除掉地址中的哪些邮箱类信息(可能会干扰经纬度抓取的准确性)

myfulldata<-rbind(economic,mangement) myfulldata$Address<-sub("\\(\\d.+\\)","",myfulldata$Address) myfulldata$Address<-sub("\\(\\d.+\\)","",myfulldata$Address) myfulldata$Address<-sub("\\d.+\\信箱","",myfulldata$Address)

使用过百度地图的API匹配经纬度(各位小伙伴儿高抬贵手,自己去申请个API把,不要老拿我的API玩耍,这个有限额,用完了就不能用了)

baidu_lng <- c() baidu_lat <- c() ak<-"X8zlxPUdSe2weshrZ1WqnWxb43cfBI2N" address<-myfulldata$Address for(location in address){ url<-paste("http://api.map.baidu.com/geocoder/v2/?ak=",ak,"&callback=renderOption&output=json&address=",location,sep="") url_string <- URLencode(url) json<- readLines(url_string, warn=F) geo <- fromJSON(substr(json,regexpr("\\(",json)+1,nchar(json)-1)) lng<-geo$result$location$lng lat<-geo$result$location$lat baidu_lng<-c(baidu_lng,lng) baidu_lat<-c(baidu_lat,lat)

}

result<-data.frame(address=address,longitude=baidu_lng,latitude=baidu_lat,stringsAsFactors=FALSE)

合并经纬度数据:

mynewfulldata<-merge(myfulldata,result,by.x="Address",by.y="address",all.x=T) mynewfulldata<-unique(mynewfulldata) mynewfulldata<-mynewfulldata[,c(2,1,4,5,3)];names(mynewfulldata)[3:4]<-c("lon","lat")

中国地图素材导入:

china_map <- readShapePoly("D:/R/rstudy/CHN_adm/bou2_4p.shp") china_map1 <- fortify(china_map)

接下来我们通过几张图表来展示社科经管类核心期刊的地域分布、城市分布情况。

经管类总体数量分布:

提取出所有的地址中地级市数量:

diyufenbujing<-myfulldata$Address diyufenbu<-sub("中国","",diyufenbujing) part1<-grep("市",diyufenbu,value=T) part1<-sub("(安徽|四川省|湖南省)","",part1) order<-gregexpr("市",part1) city<-c() for(j in 1:length(part1)){ city<-substring(part1,0,order[[j]][1]) } part2<-grep("市",diyufenbu,value=T,invert =T) part2<-sub("四川","",part2) cityvalue2<-paste0(substring(part2,1,2),"市") cityvalue<-c(city,cityvalue2)%>%count()%>%arrange(-freq)

所有核心期刊的城市分布情况

CairoPNG(file="hexinqikanall.png",width=800,height=600) font.add("myfont","msyh.ttc") showtext.begin() ggplot(cityvalue,aes(reorder(x,freq),freq))+ geom_bar(fill="#0C8DC4",stat="identity")+ coord_flip()+ labs(title="经管类核心期刊数量城市分布",caption="数据来源:百度百科")+ geom_text(aes(label=freq),hjust=1.2,colour="white",size=8)+ theme_bw()+ theme( panel.border=element_blank(), panel.grid.major=element_line(linetype="dashed"), panel.grid.minor=element_blank(), plot.title=element_text(size=15,colour="#003087",family="myfont"), plot.caption=element_text(hjust=0,size=10), axis.title=element_blank(), axis.text=element_text(size=15) ) showtext.end() dev.off()

经济学核心期刊城市分布:

diyufenbujingji<-myfulldata[which(myfulldata$Class=="C"),]$Address diyufenbujingji<-sub("中国","",diyufenbujingji) part1<-grep("市",diyufenbujingji,value=T) part1<-sub("(河南省|湖南省)","",part1) order<-gregexpr("市",part1) city<-c() for(j in 1:length(part1)){ city<-substring(part1,0,order[[j]][1]) } part2<-grep("市",diyufenbujingji,value=T,invert =T) cityvalue2<-paste0(substring(part2,1,2),"市") cityvalue<-c(city,cityvalue2)%>%count()%>%arrange(-freq)

setwd("F:/微信公众号/公众号——数据小魔方/2017年3月/20170319") CairoPNG(file="jingjixue1.png",width=900,height=620) font.add("myfont","msyh.ttc") showtext.begin() ggplot(cityvalue,aes(reorder(x,freq),freq))+ geom_bar(fill="#0C8DC4",stat="identity")+ coord_flip()+ labs(title="经济学核心期刊城市分布",caption="数据来源:百度百科")+ geom_text(aes(label=freq),hjust=1,colour="white",size=7)+ theme_bw()+ theme( panel.border=element_blank(), panel.grid.major=element_line(linetype="dashed"), panel.grid.minor=element_blank(), plot.title=element_text(size=15,colour="#003087",family="myfont"), plot.caption=element_text(hjust=0,size=10), axis.title=element_blank(), axis.text=element_text(size=15) ) showtext.end() dev.off()

管理学核心期刊城市分布:

diyufenbujinggl<-myfulldata[which(myfulldata$Class=="M"),]$Address diyufenbujinggl<-sub("中国","",diyufenbujinggl) part1<-grep("市",diyufenbujinggl,value=T) part1<-sub("(安徽省|四川省)","",part1) order<-gregexpr("市",part1) city<-c() for(j in 1:length(part1)){ city<-substring(part1,0,order[[j]][1]) } part2<-grep("市",diyufenbujinggl,value=T,invert =T) cityvalue2<-paste0(substring(part2,1,2),"市") cityvalue2<-c(city,cityvalue2)%>%count()%>%arrange(-freq)

CairoPNG(file="jingjixue2.png",width=800,height=600) font.add("myfont","msyh.ttc") showtext.begin() ggplot(cityvalue2,aes(reorder(x,freq),freq))+ geom_bar(fill="#0C8DC4",stat="identity")+ coord_flip()+ labs(title="管理学核心期刊数量城市分布",caption="数据来源:百度百科")+ geom_text(aes(label=freq),hjust=2,colour="white",size=10)+ theme_bw()+ theme( panel.border=element_blank(), panel.grid.major=element_line(linetype="dashed"), panel.grid.minor=element_blank(), plot.title=element_text(size=15,colour="#003087",family="myfont"), plot.caption=element_text(hjust=0,size=10), axis.title=element_blank(), axis.text=element_text(size=15) ) showtext.end() dev.off()

下面我们通过几张数据地图来观察一下这些期刊在地图空间分布上的趋势。

首先是经济学类核心期刊

mynewfulldata1<-filter(mynewfulldata,Class=="C") CairoPNG(file="hexinqikanC.png",width=1200,height=640) font.add("myfont","msyh.ttc") showtext.begin() ggplot()+ geom_polygon(data=china_map1,aes(x=long,y=lat,group=group),col="grey60",fill="white",size=.2,alpha=.4)+ geom_polygon(data=mynewfulldata,aes(x=lon,y=lat,fill = ..level..),stat="density_2d",alpha=.8,color=NA)+ geom_point(data=mynewfulldata,aes(x=lon,y=lat),shape=21,size=3,fill="orange",col="white")+ scale_fill_gradient2(low="white",mid="yellow", high = "red")+ coord_map("polyconic")+ guides(fill=FALSE)+ labs(title="经济学核心期刊地域分布密度图",caption="数据来源:百度百科")+ theme( title=element_text(family="myfont",size=18), plot.title=element_text(size=24), panel.grid=element_blank(), panel.background=element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), axis.title = element_blank(), plot.caption=element_text(hjust=0) ) showtext.end() dev.off()

管理学核心期刊

mynewfulldata2<-filter(mynewfulldata,Class=="M") CairoPNG(file="hexinqikanM.png",width=1200,height=640) font.add("myfont","msyh.ttc") showtext.begin() ggplot()+ geom_polygon(data=china_map1,aes(x=long,y=lat,group=group),col="grey60",fill="white",size=.2,alpha=.4)+ geom_polygon(data=mynewfulldata2,aes(x=lon,y=lat,fill = ..level..),stat="density_2d",alpha=.8,color=NA)+ geom_point(data=mynewfulldata2,aes(x=lon,y=lat),shape=21,size=3,fill="#0C8DC4",col="white")+ scale_fill_gradient2(low="white",mid="yellow", high = "red")+ coord_map("polyconic")+ guides(fill=FALSE)+ labs(title="管理学核心期刊地域分布密度图",caption="数据来源:百度百科")+ theme( title=element_text(family="myfont",size=18), plot.title=element_text(size=24), panel.grid=element_blank(), panel.background=element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), axis.title = element_blank(), plot.caption=element_text(hjust=0) ) showtext.end() dev.off()

最后来个经济学和管理学核心期刊分布对比图。

CairoPNG(file="jingguanphoto.png",width=1200,height=640) font.add("myfont", "msyh.ttc") showtext.begin() ggplot()+ geom_polygon(data=china_map1,aes(x=long,y=lat,group=group),col="grey60",fill="white",size=.2,alpha=.4)+ geom_point(data=mynewfulldata,aes(x=lon,y=lat),shape=21,size=8,fill="transparent",col="#014D64")+ geom_point(data=mynewfulldata2,aes(x=lon,y=lat),shape=21,size=3,fill="#C72E29",col="transparent",alpha=.6)+ coord_map("polyconic") + labs(title="中国社科类经管核心期刊地域分布图",caption="数据来源:百度百科")+ annotate("text", x=63.4, y=45, label="○ C: 经济学", color= "#014D64", size=6.5) + annotate("text", x=65, y=42, label=" ● M: 管理学", color= "#C72E29", size=6) + theme( title=element_text(family="myfont",size=18), plot.title=element_text(size=24), plot.caption=element_text(family="myfont",size=18,hjust=0), panel.grid = element_blank(), panel.background = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), axis.title = element_blank(), legend.position = c(0.02,0.6), ) showtext.end() dev.off()

不知道大家看了以上核心期刊的地域分布滞后,内心作何感想呢,本来想写几句短评到的,但是害怕被喷,再者自己是个学渣,这个话题不适合我~—~,有啥感想,都可以写在底部评论里,让我看到你们的声音!

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-03-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 数据小魔方 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档