[R-br] Ajuda em ilustração animada!

Ivan Bezerra Allaman ivanalaman em yahoo.com.br
Terça Agosto 28 20:48:22 BRT 2012


Bom dia senhores!

Estou fazendo uma ilustração animada para demonstrar que a média é influenciada por valores extremos com o seguinte código:

png(file='exemplos/med0%1d.png',width=500,height=250)
x1 <- list()
medias <- list()
for(i in 1:10){
    x <- c(7,10,13.4,15.3,17.6,19.5,20.6,21.1)
    y <- rep(0,8)
    x1[[i]] <- c(x,i+21.1)
    medias[[i]]  <- mean(x1[[i]])
    plot(x,y,ylim=c(0,5),xlim=c(0,35),ylab='',xlab='',axes=F)  
    axis(1)
    par(xpd=TRUE)
    points(mean(x),-0.2,col='blue',lwd=10,pch=2)
    points(x1[[i]][9],0,col='red',lwd=7,cex=0.1)
    points(medias[[i]],-0.2,col='blue',lwd=10,pch=2)
}
dev.off()

png(file='exemplos/med1%1d.png',width=500,height=250)
x2 <- list()
medias2 <- list()
for(j in seq(10,1,-1)){
    x2[[j]] <- c(12.3-j,x)
    medias2[[j]] <- mean(x2[[j]])
    plot(x,y,ylim=c(0,5),xlim=c(0,35),ylab='',xlab='',axes=F)  
    axis(1)
    par(xpd=TRUE)
    points(mean(x),-0.2,col='blue',lwd=10,pch=2)
    points(x1[[j]][9],0,col='red',lwd=7,cex=0.1)
    points(medias[[j]],-0.2,col='blue',lwd=10,pch=2)
}
dev.off()

png(file='exemplos/med2%1d.png',width=500,height=250)
for(j in 1:10){
    x2[[j]] <- c(12.3-j,x)
    medias2[[j]] <- mean(x2[[j]])
    plot(x,y,ylim=c(0,5),xlim=c(0,35),ylab='',xlab='',axes=F)  
    axis(1)
    par(xpd=TRUE)
    points(mean(x),-0.2,col='blue',lwd=10,pch=2)
    points(x2[[j]][1],0,col='red',lwd=7,cex=0.1)
    points(medias2[[j]],-0.2,col='blue',lwd=10,pch=2)
}
dev.off()


É possível juntar isso em um único código?

Desde já grato por qualquer ajuda.

(S,f,P)
Allaman


\begin{signature}
<<>>=
Prof. Dr. Ivan Bezerra Allaman
Universidade Estadual de Santa Cruz
Departamento de Ciências Exatas e Tecnológicas
Ilhéus/BA - Brasil
Fone: +55 73 3680-5596
E-mail: ivanalaman em yahoo.com.br/ivanalaman em gmail.com
@
\end{signature}
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20120828/58f6f860/attachment.html>


Mais detalhes sobre a lista de discussão R-br