knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Use the example percent positive data by age group to test creating a P chart

In this example we will create charts for age group, rather than location Hence some of the variable names will still refer to place settings rather than age group

#===============================================================================
# Set up all the library connections we need
#===============================================================================

library(shewhart.hybrid)

library(httr)
library(DT)
library(tidyverse)
library(broom)
library(readr)
library(lubridate)
library(magrittr)
library(plotly)
library(pander)
panderOptions("table.split.table", Inf)

View the data (included in the shewhart.hybrid package:)

print(Pchart_Test_Data)
#===============================================================================
# Calculate place setting as integer values 
# (in this case age group rather than place)  
#===============================================================================

Pchart_Test_Data$stateR = rank(Pchart_Test_Data$place, ties.method = "min")
Pchart_Test_Data$StateRR = match(Pchart_Test_Data$stateR, sort(unique(Pchart_Test_Data$stateR)))

Place_END = max(Pchart_Test_Data$StateRR)


#===============================================================================
# Work through each setting (age group) to calculate the limits 
# based on a P chart
#===============================================================================
OutputData = NULL

k=1
for (k in 1:Place_END) {
  Statei = 
    filter(Pchart_Test_Data, StateRR == k) %>%
    P_Chart() %>% suppressWarnings()


  OutputData %<>% bind_rows(Statei)

} #k Setting Loop
temp = OutputData %>% dplyr::filter(place == "12-14")
plot_run_chart(data = temp, mode1 = "lines")
Summ_Tab = summarize_p_chart(OutputData)

pander(Summ_Tab)


UCLA-PHP/shewhart.hybrid documentation built on Oct. 2, 2022, 8:48 p.m.