This function uses sample data, a value column, and a categorical column to create an interactive control chart using ggplot2 and plotly. The points on the chart will be colored according to the categorical values. The control line and warning limit are drawn on the chart.

get_analysis_plot(
  df,
  value_column,
  cat_column,
  target_value,
  limit,
  hard_limit
)

Arguments

df

A dataframe containing the sample data to be analyzed

value_column

A string representing the name of the column containing the values to be analyzed

cat_column

A string representing the name of the categorical column used to color the points

target_value

A numeric value indicating the control target value

limit

A numeric value indicating the control limit

hard_limit

A numeric value indicating the warning limit

Value

An interactive control chart using plotly

Examples

# Create a sample dataframe
df <- data.frame(values = c(10.2, 10.5, 10.1, 10.3, 9.9, 10.6, 10.2, 10.3, 10.4, 10.5),
category = c("A", "B", "A", "C", "B", "C", "A", "B", "C", "A"))

# Define the value and categorical columns, control limit, and warning limit
value_column <- "values"
cat_column <- "category"
limit <- 10.5
hard_limit <- 10.2
target_value <- 11

# Get the control chart with plotly
get_analysis_plot(df, value_column, cat_column, target_value, limit, hard_limit)