# Read Excel
1) readxl package
library (readxl)
path<-"D:\\xiangmu\\lixueyuan\\data1.xls"
data<-read_excel(path,range="A1:BU221")
2) the data bit count and a column format dataframe
as.data.frame(table(data$性别)) ##进行计数
3) The count display and a ratio of the bracketed
label_value <- paste('(', round(df$nums/sum(df$nums) * 100, 1), '%)', sep = '')
Results:
"(53.2%)" "(46.8%)"
will be added to the tag sex
label <- paste(df$type, label_value, sep = '')
Result: The
"male (53.2%)," "female (46.8%)."
4) Figure gender proportion yourselves and present information
ggplot(data=df, aes(x="性别",y=nums,fill=type))+
geom_bar(width = 7,stat ="identity")+ ##width用来调整文本与圆环大小
coord_polar("y", start=0)+
scale_fill_manual(values=c('#FE8463', '#60C0DD' ))+ ##对原有填充颜色进行改变
labs(x = '', y = '', title = '')+
theme(axis.ticks = element_blank())+
theme(axis.text.x = element_blank()) +
theme(legend.position = "none") +
theme(panel.background = element_rect(fill='white', colour='pink'))+ ##调整图片背景颜色与背景边框颜色
geom_text(aes(y = df$nums/2 + c(0, cumsum(df$nums)[-length(df$nums)]), x = sum(df$nums)/3500, label = label),size=4,color='white') ##文本显示 男女比例
5) draw a map with rechart
city <-c('安徽','福建','甘肃','广东','广西','贵州','河北','河南','湖北','湖南','江苏','江西','辽宁','内蒙古','山东','山西','陕西','四川', '新疆','云南','浙江','重庆')
as.character(city)
value<-c(101,40,60,35, 105, 150, 50, 110, 39, 35, 25, 80, 15, 20, 40, 66, 35, 80, 25, 67, 150,0)
as.character(value)
cdata <- data.frame(city,value)
library(devtools)
install_github('lchiffon/REmap')
library(REmap)
library(recharts)
a<-data.frame('浙江省',121.56,29.8)
echartr(cdata,city, value, type='map_china')%>%
setDataRange(splitNumber=0, valueRange=range(0,150),
color=c('red','orange','pink')) %>%
setToolbox(show = FALSE)%>%
setLegend(show = FALSE)%>%
setTitle(title='萌新地区分布图', pos=12,
textStyle=textStyle(fontFamily='Courier New', fontSize=24))%>%
addMP(
series="浙江",
data=data.frame(name='浙江省',value=2426),
symbol ='emptyCircle',
symbolSize=10,
effect = list(show=T))%>%
addGeoCoord(a)
But it has not displayed directly provinces and the number
and use mapping can show the number of pages echart
https://echarts.baidu.com/echarts2/doc/example.html
6) Figure painting echart
students distributed
xueyuan<-as.data.frame(table(data$`专业名称(匹配)`))
View(xueyuan)
names(xueyuan)<-c('学院','人数')
echartr(xueyuan,学院,人数)
7) surname word cloud
library(stringr)
xingshi<-str_sub(data$姓名, 1, 1)
xingshi<-as.data.frame(table(xingshi))
library(wordcloud2)
wordcloud2(xingshi, size = 1, minSize = 0, gridSize = 0,
fontFamily = 'Segoe UI', fontWeight = 'bold',
color = 'random-dark', backgroundColor = "pink",
minRotation = -pi/4, maxRotation = pi/4, shuffle = TRUE,
rotateRatio = 0.4, shape = 'star', ellipticity = 0.65,
widgetsize = NULL, figPath = NULL, hoverFunction = NULL)
And a echart do some nice FIG
color scheme: '# C1232B', '# B5C334', '# FCCE10', '# E87C25', '# 27727B',
'# FE8463', '# 9BCA63', '# FAD860' , '# F3A43B', '# 60C0DD',
'# D7504B', '# C6E579', '# F4E001', '# F0805A', '# 26C0C0'
The effect of moving map Cai million recorded using the master screen moving map display and do pr
8) information filtering, choose a column containing a word
data1<-data%>%
filter(考生特长 %in% '舞')