#install.packages("plotrix") x<-c(1,2,3,4,5,6,7,8,9,10) x y<-rep(c(1,2,3,4,5), each=2) y a<-data.frame(x,y) a exercicio.2<- function(x,y) { if (length (x)==length (y)) { x11() par(mfrow = c(3,2)) library(plotrix) multhist(list(x,y)) density.x<-density(x) density.y<-density(y) plot(NA, xlab="", ylab="", xlim=c(0,max(density.x$x, density.y$x)), ylim=c(0,max(density.x$y, density.y$y))) lines(density.x, col="red") lines(density.y, col="blue") boxplot(x,y, xaxis="n", col=c("red", "blue")) axis(1, 1:2, c("x", "y")) plot(y~x) qqnorm(x, col="red", main="QQ Plot de x") qqnorm(y, col="blue", main="QQ Plot de y") par(mfrow=c(1,1)) return (list(summary(x),summary(y), cor(x,y))) } else { stop ("x e y devem ter o mesmo tamanho") } }