R/fct_core.R
get_analysis_plot.RdThis 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
)A dataframe containing the sample data to be analyzed
A string representing the name of the column containing the values to be analyzed
A string representing the name of the categorical column used to color the points
A numeric value indicating the control target value
A numeric value indicating the control limit
A numeric value indicating the warning limit
An interactive control chart using plotly
# 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)