#Cochrane Test for more that two populations library(dplyr) library(ggplot2) library(reshape2) library(DescTools) #Set working directory setwd("~/Dropbox/ISI SCB/Data sets") # read in csv file machines<-read.csv("machines.csv", TRUE) mh <- as.matrix(machines[,2:5]) #create tables Machine1 <-table(mh[,1]) Machine2 <-table(mh[,2]) Machine3 <-table(mh[,3]) Machine4 <-table(mh[,4]) m4 <- rbind(Machine1, Machine2, Machine3, Machine4) m4 #set up data frame to generate bar charts #1 Change column names to labels m4_new <-m4 colnames(m4_new) <- c("No", "Yes") m4_new #2 set up data to generate bar charts m4_m <- melt(m4_new, varnames = c("Machine", "Acceptable"), id.vars = "Acceptable") #bar charts ggplot(m4_m %>% group_by(Machine) %>% mutate(Frequency= value,3), aes(x=Machine, y = Frequency, fill = Acceptable, cumulative = TRUE)) + geom_col() + geom_text(aes(label = paste0(Frequency)), position = position_stack(vjust = 0.5)) #Cochrane Test CochranQTest(mh)