plotEX.data.frame作业

plotEx.data.frame <- function (x, ...)
{
plot2 <- function(x, xlab = names(x)[1L], ylab = names(x)[2L],
...) plot(x[[1L]], x[[2L]], xlab = xlab, ylab = ylab,
...)
if (!is.data.frame(x))
stop("'plot.data.frame' applied to non data frame")+ if (ncol(x) == 1) {
x1 <- x[[1L]]
cl <- class(x1)
if (cl %in% c("integer", "numeric"))
if(length(unique(x1))<=5){
pie(table(x1))
stripchart(x1, ...)
}

else plot(x1, ...)
}
else if (ncol(x) == 2) {
x1 <- x[[1L]]
x2 <- x[[2L]]
if(length(unique(x1))<=5) {
if(length(unique(x2))<=5) {
mosaic(ta<-table(x1,x2))
}
else {boxplot(x2~x1)
points(x1,jitter(x2))
}
}
else{cdplot(x2~x1)
}
}
else {
pairs(data.matrix(x), ...)
}

 

绘图作业

> Dataset = read.csv('http://fudan.lxxm.com/wp-content/uploads/2012/12/Prac.csv',encoding='GBK')
>attach(Dataset)
>N <- nrow(Dataset)
>symbols(Life.Expectancy,Governance_Rank,circle=sqrt(Population/pi),inches=0.3,fg="white",bg=rainbow(N),main="the relationship among Life.Expectancy~Population~Governance_Rank")