I am using the qcc package. I am running a simple process.capability plot inside of a loop for multiple materials. As it loops through the columns, the title of the plot is always the df.1[i], rather than the column name.
process.capability(qcc(df.1[i], type="xbar.one"), nsigmas = 3, spec.limits = c(NA, 20), add.stats = T)
Or conversely, is it possible to use the actual column name while still in the loop?
process.capability(qcc(df.1$Aluminum, type="xbar.one"), nsigmas = 3, spec.limits = c(NA, 20), add.stats = T)
Full loop below:
for (i in 5:length(colnames(df.1))){
df.2 <- df.1 %>%
rename(test_metal = colnames(df.1[i]))
test_group = with(df.2, qcc.groups(test_metal, batch_num))
png("test_plot.png")
q1 <- qcc(test_group, type = "xbar.one", nsigmas = 3, chart.all = F, ylim = c(0, max(df.1$Aluminum)), title = paste(colnames(df.1)[i]))
dev.off()
}