Ozone Solar.R Wind Temp
Min. : 1.00 Min. : 7.0 Min. : 1.700 Min. :56.00
1st Qu.: 18.00 1st Qu.:115.8 1st Qu.: 7.400 1st Qu.:72.00
Median : 31.50 Median :205.0 Median : 9.700 Median :79.00
Mean : 42.13 Mean :185.9 Mean : 9.958 Mean :77.88
3rd Qu.: 63.25 3rd Qu.:258.8 3rd Qu.:11.500 3rd Qu.:85.00
Max. :168.00 Max. :334.0 Max. :20.700 Max. :97.00
NA's :37 NA's :7
Month Day
Min. :5.000 Min. : 1.0
1st Qu.:6.000 1st Qu.: 8.0
Median :7.000 Median :16.0
Mean :6.993 Mean :15.8
3rd Qu.:8.000 3rd Qu.:23.0
Max. :9.000 Max. :31.0
# 安装并加载所需包library(hexbin)library(ggplot2)
4.2 图形3——六边形分箱散点图
# 计算相关系数(移除NA)cor_val <-round(cor(airquality$Solar.R, airquality$Ozone, use ="complete.obs"), 2)ggplot(na.omit(airquality), aes(x = Solar.R, y = Ozone)) +geom_hex(bins =15, alpha =0.8) +geom_smooth(method ="lm", color ="red", se =FALSE) +# 添加回归线scale_fill_gradientn(colors =c("#f0f9e8", "#bae4bc", "#7bccc4", "#43a2ca", "#0868ac")) +annotate("text", x =50, y =150, label =paste("相关系数 =", cor_val),color ="red", size =5) +labs(title ="太阳辐射与臭氧浓度的密度关系",subtitle ="纽约市1973年5-9月每日测量数据",caption ="数据来源:纽约州环境保护部") +theme_bw() +theme(plot.title =element_text(face ="bold"))
ID Degree Betweenness Closeness Eigenvector Community Leader
Mr Hi Mr Hi 16 250.150000 0.007692308 0.8578794 1 Leader
Actor 2 Actor 2 9 33.800000 0.006060606 0.8287662 1 Member
Actor 3 Actor 3 10 36.650000 0.005952381 0.9903645 1 Member
Actor 4 Actor 4 6 1.333333 0.005347594 0.5453691 1 Member
Actor 5 Actor 5 3 0.500000 0.004629630 0.1529119 2 Member
Actor 6 Actor 6 4 15.500000 0.004608295 0.1851927 2 Member