In [1]:
# rm(list=ls()) 
options(OutDec = ",")
#===============================================================================
In [2]:
#===============================================================================
# Dados da Tabela 2.3
#===============================================================================
dados <- read.csv("../dados/Tabela-2-3.csv",sep=";",dec=",",header=F)
colnames(dados) <- c("Xi1","Xi2","Xi3","Xi4","Xi5")
print(dados)
      Xi1    Xi2    Xi3    Xi4    Xi5
1  1001,7 1004,0 1004,8  996,3 1004,3
2   999,7 1000,3 1003,2  993,9  998,9
3   990,9 1004,0 1003,0 1004,0 1002,0
4  1000,7 1007,3  998,1  995,5  994,9
5  1000,7  998,3  998,9  997,8 1001,9
6   998,6  993,7 1002,8  995,5  994,1
7  1002,7 1010,5  990,5  992,5 1003,0
8  1000,4 1004,0 1003,0  999,8  997,2
9   999,9 1005,6  996,1 1005,5  998,1
10  994,3  993,2 1005,8  996,4  996,7
11  997,4  997,1  998,0  995,6 1005,8
12 1003,5  992,3 1000,8 1000,0 1001,2
13 1003,4 1004,6 1001,3  997,3 1005,8
14  997,7 1004,6  997,0 1001,0 1003,9
15 1012,0 1007,0 1002,7 1008,0 1005,0
In [3]:
#===============================================================================
# Calculando a média e a amplitude para cada amostra.
#===============================================================================
xbar.i <- apply(dados,1,"mean")
R.i    <- as.vector(diff(apply(dados,1,"range")))
print(cbind(dados,xbar.i,R.i))
      Xi1    Xi2    Xi3    Xi4    Xi5  xbar.i  R.i
1  1001,7 1004,0 1004,8  996,3 1004,3 1002,22  8,5
2   999,7 1000,3 1003,2  993,9  998,9  999,20  9,3
3   990,9 1004,0 1003,0 1004,0 1002,0 1000,78 13,1
4  1000,7 1007,3  998,1  995,5  994,9  999,30 12,4
5  1000,7  998,3  998,9  997,8 1001,9  999,52  4,1
6   998,6  993,7 1002,8  995,5  994,1  996,94  9,1
7  1002,7 1010,5  990,5  992,5 1003,0  999,84 20,0
8  1000,4 1004,0 1003,0  999,8  997,2 1000,88  6,8
9   999,9 1005,6  996,1 1005,5  998,1 1001,04  9,5
10  994,3  993,2 1005,8  996,4  996,7  997,28 12,6
11  997,4  997,1  998,0  995,6 1005,8  998,78 10,2
12 1003,5  992,3 1000,8 1000,0 1001,2  999,56 11,2
13 1003,4 1004,6 1001,3  997,3 1005,8 1002,48  8,5
14  997,7 1004,6  997,0 1001,0 1003,9 1000,84  7,6
15 1012,0 1007,0 1002,7 1008,0 1005,0 1006,94  9,3
In [4]:
#===============================================================================
# Definindo os limites de controle.
# Observação: aprenderemos a calcular estes limites ao longo da disciplina.
#===============================================================================
# Para a média amostral (xbar.i)
LSC.xbarra <- 1006
LM.xbarra  <- 1000
LIC.xbarra <-  994

# Para a amplitude amostral (R.i)
LSC.R      <- 22.21
LM.R       <- 10.5
LIC.R      <-  0
In [5]:
#===============================================================================
# Gráfico de controle de xbarra.
#===============================================================================
par(mfrow=c(1,1),lwd=2.0,cex.lab=1.5,cex.axis=1.5,lab=c(10,5,5),
    mar=c(5,5,2,2.5),xpd=T,cex.main=2.0,bty="n")
plot(1:15,xbar.i,type="l",lwd=2,col="darkblue",main="",xlim=c(0,20),
     ylim=c(990,1010),xlab="Número da amostra",ylab=expression(bar(X)))
points(1:15,xbar.i,pch=16,cex=2,col="darkblue")
lines(0:18,rep(LSC.xbarra,19),lwd=3,col="red",lty=2)
lines(0:18,rep(LM.xbarra,19), lwd=3,col="red",lty=3)
lines(0:18,rep(LIC.xbarra,19),lwd=3,col="red",lty=2)
text(19.5,LSC.xbarra,"LSC",cex=1.5,lwd=2)
text(19.5,LM.xbarra, "LM", cex=1.5,lwd=2)
text(19.5,LIC.xbarra,"LIC",cex=1.5,lwd=2)
No description has been provided for this image
In [6]:
#===============================================================================
# Gráfico de controle de R.
#===============================================================================
par(mfrow=c(1,1),lwd=2.0,cex.lab=1.5,cex.axis=1.5,lab=c(10,5,5),
    mar=c(5,5,2,2.5),xpd=T,cex.main=2.0,bty="n")
plot(1:15,R.i,type="l",lwd=2,col="darkblue",main="",xlim=c(0,20),
     ylim=c(0,25),xlab="Número da amostra",ylab=expression(R))
points(1:15,R.i,pch=16,cex=2,col="darkblue")
lines(0:18,rep(LSC.R,19),lwd=3,col="red",lty=2)
lines(0:18,rep(LM.R,19), lwd=3,col="red",lty=3)
lines(0:18,rep(LIC.R,19),lwd=3,col="red",lty=2)
text(19.5,LSC.R,"LSC",cex=1.5,lwd=2)
text(19.5,LM.R, "LM", cex=1.5,lwd=2)
text(19.5,LIC.R,"LIC",cex=1.5,lwd=2)
No description has been provided for this image
In [7]:
#===============================================================================
# Fim
#===============================================================================