R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.


🧮 4. Código del gráfico de control

# Instalar e importar librería
# install.packages("qcc")
library(qcc)
## Warning: package 'qcc' was built under R version 4.5.1
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
# Datos de ejemplo 
defectuosos <- c(4, 6, 5, 9, 7, 8, 6, 5, 7, 10, 8, 9, 5, 6, 7, 8, 6, 9, 7, 8)
tamano_muestra <- rep(120, 20) # tamaño de muestra constante

# Gráfico p
qcc(defectuosos, sizes = tamano_muestra, type = "p", title = "Gráfico de Control p - Producción 2025")

## List of 11
##  $ call      : language qcc(data = defectuosos, type = "p", sizes = tamano_muestra, title = "Gráfico de Control p - Producción 2025")
##  $ type      : chr "p"
##  $ data.name : chr "defectuosos"
##  $ data      : num [1:20, 1] 4 6 5 9 7 8 6 5 7 10 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:20] 0.0333 0.05 0.0417 0.075 0.0583 ...
##   ..- attr(*, "names")= chr [1:20] "1" "2" "3" "4" ...
##  $ sizes     : num [1:20] 120 120 120 120 120 120 120 120 120 120 ...
##  $ center    : num 0.0583
##  $ std.dev   : num 0.234
##  $ nsigmas   : num 3
##  $ limits    : num [1:20, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"
## Gráfico np
qcc(defectuosos, sizes = tamano_muestra, type = "np", title = "Gráfico de Control np - Producción 2025")

## List of 11
##  $ call      : language qcc(data = defectuosos, type = "np", sizes = tamano_muestra, title = "Gráfico de Control np - Producción 2025")
##  $ type      : chr "np"
##  $ data.name : chr "defectuosos"
##  $ data      : num [1:20, 1] 4 6 5 9 7 8 6 5 7 10 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:20] 4 6 5 9 7 8 6 5 7 10 ...
##   ..- attr(*, "names")= chr [1:20] "1" "2" "3" "4" ...
##  $ sizes     : num [1:20] 120 120 120 120 120 120 120 120 120 120 ...
##  $ center    : num 7
##  $ std.dev   : num 2.57
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] 0 14.7
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"
defectos <- c(2, 3, 4, 5, 3, 6, 3, 4, 5, 3, 2, 6, 4, 3, 5, 4, 2, 5, 3, 4)
qcc(defectos, type = "c", title = "Gráfico de Control c - Inspección 2025")

## List of 11
##  $ call      : language qcc(data = defectos, type = "c", title = "Gráfico de Control c - Inspección 2025")
##  $ type      : chr "c"
##  $ data.name : chr "defectos"
##  $ data      : num [1:20, 1] 2 3 4 5 3 6 3 4 5 3 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:20] 2 3 4 5 3 6 3 4 5 3 ...
##   ..- attr(*, "names")= chr [1:20] "1" "2" "3" "4" ...
##  $ sizes     : int [1:20] 1 1 1 1 1 1 1 1 1 1 ...
##  $ center    : num 3.8
##  $ std.dev   : num 1.95
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] 0 9.65
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"