Central University of Finance and Economics
School of Statistics and Mathematics
Follow me on ins:cheer.dictpro
Email:dzdyw@email.cufe.edu.cn
(1)
setwd("C:\\Users\\Mr.Young\\Desktop")
X <- read.csv("1-1.csv", header = T)
attach(X)
XX <- data.frame(X$OXY, X$time, X$age)
plot(XX)
(2)
plot(X[2:8])
pairs(X[2:8])
library("car")
scatterplotMatrix(X[2:8], spread = FALSE,
smoother = FALSE)
(3)
X3 <- X[c(1,2,21,22), ]
library(lattice)
parallelplot(~X3[2:8], horizontal.axis = FALSE)
轮廓图编程
outline <- function(x){
if (is.data.frame(x) == TRUE)
x <- as.matrix(x)
m <- nrow(x); n <- ncol(x)
plot(c(1,n), c(min(x),max(x)), type = "n",
main = "The outline graph of Data",
xlab = "Number", ylab = "Value")
for(i in 1:m){
lines(x[i,], col=i, lty = i)
}
}
outline(X3[2:8])
legend("topleft", title = "Order Number",
legend = c("1","2","21","22"),
lty = 1:4, col = 1:4)
library(fmsb)
radarchart(X3[2:8],axistype = 2,plty = 3:6,seg = 3,
maxmin = FALSE,title = "Radar Chart")
legend(x = 1.2, y = 1.2,
legend = c("1","2","21","22"),
lty = 3:6,col = c("black","red","green","blue"))
(4)
library(andrews)
andrews(X3[2:8], type = 1, ymax = 5,
main = "Harmonic Diagram")
library(MSG)
andrews_curve(X3[2:8])
调和曲线图编程
unison <- function(x){
if (is.data.frame(x) == TRUE)
x <- as.matrix(x)
t <- seq(-pi, pi, pi/30)
m <- nrow(x); n<-ncol(x)
f <- array(0, c(m,length(t)))
for(i in 1:m){
f[i,] <- x[i,1]/sqrt(2)
for( j in 2:n){
if (j%%2 == 0)
f[i,] <- f[i,]+x[i,j]*sin(j/2*t)
else
f[i,] <- f[i,]+x[i,j]*cos(j%/%2*t)
}
}
plot(c(-pi,pi), c(min(f), max(f)), type = "n",
main = "Harmonic Diagram",
xlab = "t", ylab = "f(t)")
for(i in 1:m) lines(t, f[i,] , col = i, lty = i)
}
unison(X3[2:8])
legend("topleft", title = "Order Number",
legend = c("1","2","21","22"),
lty = 1:4, col = 1:4)
脸谱图
library(aplpack)
## Loading required package: tcltk
faces(X3[2:8])
## effect of variables:
## modified item Var
## "height of face " "age"
## "width of face " "weight"
## "structure of face" "time"
## "height of mouth " "spulse"
## "width of mouth " "rpulse"
## "smiling " "mpulse"
## "height of eyes " "OXY"
## "width of eyes " "age"
## "height of hair " "weight"
## "width of hair " "time"
## "style of hair " "spulse"
## "height of nose " "rpulse"
## "width of nose " "mpulse"
## "width of ear " "OXY"
## "height of ear " "age"
使用函数faces(X,nrow.plot,ncol.plot,…)
X为数值矩阵,每一列代表一个变量
nrow.plot 和ncol.plot分别为图形显示的行列数
用五官的宽度和高度来描绘数值
人对脸谱高度敏感和强记忆
适合较少样本的情况
library("TeachingDemos")
##
## Attaching package: 'TeachingDemos'
##
## The following objects are masked from 'package:aplpack':
##
## faces, slider
faces2(X3[2:8])