I am working with a dataset which has three categorical variables, whether product is defective or not, type of product and factory in which the product was produced. I want to plot out two graphs:
i) The percentage defective rate for each product type and factory. For this chart I'll have a total of eight groups and their corresponding defective rate.
ii) The defect pieces per 1000 for each product type and factory based on the percentage defective rate by product and factory. Here again, I'll have a total of eight groups.
Would appreciate any help on the above.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(defective_ind product factory) 0 4 1 0 1 1 0 3 1 0 2 1 0 2 1 1 1 2 0 2 2 0 1 2 0 3 1 0 3 1 0 2 2 0 4 1 0 3 1 0 1 2 0 2 1 0 3 2 0 2 1 0 2 1 1 3 1 0 2 1 0 2 2 0 3 1 0 2 2 1 2 2 0 2 1 1 4 1 0 3 1 0 1 2 1 1 2 0 2 2 0 2 2 0 3 1 0 3 1 1 2 2 0 1 2 0 2 1 0 1 1 0 4 1 1 2 1 0 3 1 0 2 1 0 2 2 0 2 1 1 3 1 0 3 1 0 3 1 0 2 2 0 3 1 1 3 1 0 4 1 1 3 1 0 4 1 0 2 1 0 2 2 1 3 2 0 2 2 0 4 1 0 3 1 1 2 1 0 2 1 0 2 1 0 2 1 0 2 2 1 2 1 0 3 2 0 3 1 0 2 1 0 4 2 0 3 1 1 2 1 0 2 1 0 2 2 1 2 2 0 1 1 0 3 1 1 2 2 0 2 1 0 3 1 0 2 2 1 3 1 0 2 1 0 3 1 0 1 1 0 2 1 1 3 2 0 3 1 0 2 1 1 2 1 0 2 2 0 1 2 0 3 1 0 2 1 0 3 2 0 2 2 0 2 1 1 2 2 0 3 1 0 2 2 1 2 1 end label values defective_ind defec label def defec 0 "Not Defective", modify label def defec 1 "Defective", modify label values product prod label def prod 1 "Product 1", modify label def prod 2 "Product 2", modify label def prod 3 "Product 3", modify label def prod 4 "Product 4", modify label values factory fact label def fact 1 "Factory 1", modify label def fact 2 "Factory 2", modify
Alex
0 Response to Help with Bar graph of three categorical variables and rates
Post a Comment