Statistics and Probability with Applications for Engineers and Scientists Using MINITAB, R and JMP. Bhisham C. Gupta
Чтение книги онлайн.
Читать онлайн книгу Statistics and Probability with Applications for Engineers and Scientists Using MINITAB, R and JMP - Bhisham C. Gupta страница 35
6 Click Pie Options and in the new dialog box that appears select any option you like and click OK. Click Lables and in the new dialog box that appears select the Slice Labels from the box menu and select Percent option and click OK. The pie chart will appear as shown in Figure 2.4.2.
USING R
We can use the built in ‘pie()’ function in R to generate pie charts. If a pie chart with percentages desired, then the percentages of the categories should be calculated manually. Then, these percentages should be used to label the categories. The task can be completed by running the following R code in the R Console window.
Freq = c(86, 182, 83, 10) #To label categories Process = c(‘Initial cutoff’, ‘Turning’, ‘Drilling’, ‘Assembly’) #To calculate percentages Percents = round(Freq/sum(Freq)*100,1) label = paste(Percents, ‘%’, sep=‘ ’) # add % to labels #Pie Chart with percentages pie(Freq, labels = label, col=c(2,3,4,5), main=‘Pie Chart of Process Steps’) #To add a legend. Note: “pch” specifies various point shapes. legend(‘topleft’, Process, col=c(2,3,4,5), pch=15)
2.4.3 Bar Chart
Bar charts are commonly used to describe qualitative data classified into various categories based on sector, region, different time periods, or other such factors. Different sectors, different regions, or different time periods are then labeled as specific categories. A bar chart is constructed by creating categories that are represented by labeling each category and which are represented by intervals of equal length on a horizontal axis. The count or frequency within the corresponding category is represented by a bar of height proportional to the frequency. We illustrate the construction of a bar chart in the examples that follow.
Example 2.4.3 (Companies' revenue) The following data give the annual revenues (in millions of dollars) of five companies A, B, C, D, and E for the year 2011:
78, 92, 95, 94, 102
Construct a bar chart for these data.
Solution: Following the previous discussion, we construct the bar chart as shown in Figure 2.4.3.
Figure 2.4.3 Bar chart for annual revenues of five companies for the year 2011.
Example 2.4.4 (Auto part defect types) A company that manufactures auto parts is interested in studying the types of defects in parts produced at a particular plant. The following data shows the types of defects that occurred over a certain period:
2 | 1 | 3 | 1 | 2 | 1 | 5 | 4 | 3 | 1 | 2 | 3 | 4 | 3 | 1 | 5 | 2 | 3 | 1 | 2 | 3 | 5 | 4 | 3 | 1 |
5 | 1 | 4 | 2 | 3 | 2 | 1 | 2 | 5 | 4 | 2 | 4 | 2 | 5 | 1 | 2 | 1 | 2 | 1 | 5 | 2 | 1 | 3 | 1 | 4 |
Construct a bar chart for the types of defects found in the auto parts.
Solution: In order to construct a bar chart for the data in this example, we first need to prepare a frequency distribution table. The data in this example are the defect types, namely 1, 2, 3, 4, and 5. The frequency distribution table is shown in Table 2.4.2. Note that the frequency distribution table also includes a column of cumulative frequency.
Now, to construct the bar chart, we label the intervals of equal length on the horizontal line with the category types of defects and then indicate the frequency of observations associated with each defect by a bar of height proportional to the corresponding frequency. Thus, the desired bar graph, as given in Figure 2.4.4, shows that the defects of type 1 occur the most frequently, type 2 occur the second most frequently, and so on.
Table 2.4.2 Frequency distribution table for the data in Example 2.4.4.
Frequency | Relative | Cumulative | ||
Categories | Tally | or count | frequency | frequency |
1 | ///// ///// //// | 14 | 14/50 | 14 |
2 | ///// ///// /// | 13 | 13/50 | 27 |
3 | ///// //// | 9 | 9/50 | 36 |
4 | ///// // | 7 | 7/50 |