R语言笔记之散点图绘制

> library(nutshell)
载入需要的程辑包:nutshell.bbdb
载入需要的程辑包:nutshell.audioscrobbler
> data("toxins.and.cancer")
> attach(toxins.and.cancer)
> plot(total_toxic_chemicals/Surface_Area,deaths_total/Population)
R语言笔记之散点图绘制_第1张图片
散点图
> identify(total_toxic_chemicals/Surface_Area,deaths_total/Population,State_Abbrev)
[1]  3  8 16
R语言笔记之散点图绘制_第2张图片
交互加标签

给所有点加标签text()

> text(total_toxic_chemicals/Surface_Area,deaths_total/Population,
+      labels=State_Abbrev,cex=0.5,adj=c(0,-1))
R语言笔记之散点图绘制_第3张图片
给所有点加标签

求相关系数

> cor.test(total_toxic_chemicals/Surface_Area,deaths_total/Population)

    Pearson's product-moment correlation

data:  total_toxic_chemicals/Surface_Area and deaths_total/Population
t = 1.8909, df = 39, p-value = 0.06609
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.01961007  0.54853523
sample estimates:
      cor 
0.2897887
> data("batting.2008")
> pairs(batting.2008[batting.2008$AB>100,c("H","R")])
R语言笔记之散点图绘制_第4张图片
Paste_Image.png

多个变量逐对比较的散点图

>pairs(batting.2008[batting.2008$AB>100,c("H","R","SO","BB","HR")])
R语言笔记之散点图绘制_第5张图片
五个变量逐对比较

这里是选择出属性AB>100的运动员,然后两两比较他们在"H","R","SO","BB","HR"这五项中的得分。

你可能感兴趣的:(R语言笔记之散点图绘制)