1.hist() 直方图
V = read.csv("data//test1.csv")
# 显示数据
hist(V$x1,col = 1:7) #有颜色
hist(V$x2,)
2.plot()散点图 R中最强大的绘图函数
plot(V$x1,V$x2)
3.table()列联表函数
library(openxlsx)
d2.1 = read.xlsx("data/mvstats5.xlsx","d2.1")
attach(d2.1)#绑定数据 方便使用数据表中的列名
table(年龄)
4.barplot()条形图、pie()饼图
barplot(table(年龄),col = 1:7)
pie(table((年龄)),col = 1:7)
# 二维列联表
table(年龄,性别)
barplot(table(年龄,性别),beside = T,col = 1:2)
barplot(table(性别,年龄),beside = T,col = 1:2)
# 三因素分析
ftable(性别,年龄,结果)
因篇幅问题不能全部显示,请点此查看更多更全内容