【文章內(nèi)容簡介】
直方圖下的面積之和等于 1? 某電腦公司銷售量分布的直方圖 190 200 180 160 170 頻 數(shù) (天 ) 25 20 15 10 5 30 220 230 240 例 4 對(duì)公司雇員數(shù)據(jù),做出工資數(shù)據(jù)直方圖。 ? hist(Edata$SALARY) ? hist(Edata$SALARY,labels = T) H i s t o g r a m o f E d a t a $ S A L A R YE d a ta $ S A L A R YFrequency20200 40000 60000 80000 100000 140000050100150200H i s t o g r a m o f E d a t a $ S A L A R YE d a ta $ S A L A R YFrequency20200 40000 60000 80000 100000 14000005010015020033230107332622104521 0 1分組數(shù)據(jù) —直方圖 (直方圖與條形圖的區(qū)別 ) 1. 條形圖是用條形的長度 (橫置時(shí) )表示各類別頻數(shù)的多少 , 其寬度 (表示類別 )則是固定的 2. 直方圖是用面積表示各組頻數(shù)的多少 , 矩形的高度表示每一組的頻數(shù)或百分比 , 寬度則表示各組的組距 , 其高度與寬度均有意義 3. 直方圖的各矩形通常是連續(xù)排列 , 條形圖則是分開排列 4. 條形圖主要用于展示分類數(shù)據(jù) , 直方圖則主要用于展示數(shù)值型數(shù)據(jù) 分組數(shù)據(jù) —折線圖 (frequency polygon) 1. 折線圖也稱頻數(shù)多邊形圖 2. 是在直方圖的基礎(chǔ)上 , 把直方圖頂部的中點(diǎn) (組中值 )用直線連接起來 , 再把原來的直方圖抹掉 3. 折線圖的兩個(gè)終點(diǎn)要與橫軸相交 , 具體的做法是 – 第一個(gè)矩形的頂部中點(diǎn)通過豎邊中點(diǎn) ( 即該組頻數(shù)一半的位置 ) 連接到橫軸 , 最后一個(gè)矩形頂部中點(diǎn)與其豎邊中點(diǎn)連接到橫軸 – 折線圖下所圍成的面積與直方圖的面積相等 , 二者所表示的頻數(shù)分布是一致的 分組數(shù)據(jù)的圖示 (折線圖的繪制 ) 折線圖與直方圖 下的面積相等! 140 150 210 某電腦公司銷售量分布的折線圖 190 200 180 160 170 220 230 240 頻 數(shù) (天 ) 25 20 15 10 5 30 未分組數(shù)據(jù) —莖葉圖 (stemandleaf display) 1. 用于顯示未分組的原始數(shù)據(jù)的分布 2. 由 “ 莖 ” 和 “ 葉 ” 兩部分構(gòu)成 , 其圖形是由數(shù)字組成的 3. 以該組數(shù)據(jù)的高位數(shù)值作樹莖 , 低位數(shù)字作樹葉 4. 樹葉上只保留一位數(shù)字 5. 對(duì)于 n(20? n ?300)個(gè)數(shù)據(jù) , 莖葉圖最大行數(shù)不超過 ? L = [ 10 lg(n) ] ? 6. 莖葉圖類似于橫置的直方圖 , 但又有區(qū)別 ? 直方圖可觀察一組數(shù)據(jù)的分布狀況 , 但沒有給出具體的數(shù)值 ? 莖葉圖既能給出數(shù)據(jù)的分布狀況 , 又能給出每一個(gè)原始數(shù)值 , 保留了原始數(shù)據(jù)的信息 未分組數(shù)據(jù) —莖葉圖 (例題分析 ) 未分組數(shù)據(jù) —莖葉圖 (擴(kuò)展的莖葉圖 ) 未分組數(shù)據(jù) —箱線圖 (box plot) 1. 用于顯示未分組的原始數(shù)據(jù)的分布 2. 箱線圖由一組數(shù)據(jù)的 5個(gè)特征值繪制而成 , 它由一個(gè)箱子和兩條線段組成 3. 其繪制方法是: – 首先找出一組數(shù)據(jù)的 5個(gè)特征值 , 即 最大值 、 最小值 、 中位數(shù) Me 和兩個(gè) 四分位數(shù) (下四分位數(shù) QL和上四分位數(shù) QU) – 連接兩個(gè)四分 ( 位 ) 數(shù)畫出箱子 , 再將兩個(gè)極值點(diǎn)與箱子相連接 未分組數(shù)據(jù) —單批數(shù)據(jù)箱線圖 (箱線圖的構(gòu)成 ) 中位數(shù) 4 6 8 10 12 Q U Q L X 最大值 X 最小值 簡單箱線圖 未分組數(shù)據(jù) —單批數(shù)據(jù)箱線圖 (例題分析 ) 最小值 141 最大值 237 中位數(shù) 182 下四分位數(shù) 上四分位數(shù) 197 140 150 160 170 180 190 200 210 220 230 240 某電腦公司銷售量數(shù)據(jù)的箱線圖 分布的形狀與箱線圖 對(duì)稱分布 Q L 中位數(shù) Q U 左偏分布 Q L 中位數(shù) Q U 右偏分布 Q L 中位數(shù) Q U 不同分布的箱線圖 例 5 對(duì)公司雇員數(shù)據(jù),做出工資數(shù)據(jù)箱線圖。 ? boxplot(Edata$SALARY, data = Edata, col = lightgray)。 20200400006000080000120200未分組數(shù)據(jù) —多批數(shù)據(jù)箱線圖 (例題分析 ) 【 例 】 從某大學(xué)經(jīng)濟(jì)管理專業(yè)二年級(jí)學(xué)生中隨機(jī)抽取 11人 , 對(duì) 8門主要課程的考試成績進(jìn)行調(diào)查, 所得結(jié)果如表 。 試?yán)L制各科考試成績的批比較箱線圖, 并分析各科考試成績的分布特征 11名學(xué)生各科的考試成績數(shù)據(jù) 課程名稱 學(xué)生編號(hào) 1 2 3 4 5 6 7 8 9 10 11 英語 經(jīng)濟(jì)數(shù)學(xué) 西方經(jīng)濟(jì)學(xué) 市場(chǎng)營銷學(xué) 財(cái)務(wù)管理 基礎(chǔ)會(huì)計(jì)學(xué) 統(tǒng)計(jì)學(xué) 計(jì)算機(jī)應(yīng)用基礎(chǔ) 76 65 93 74 68 70 55 85 90 95 81 87 75 73 91 78 97 51 76 85 70 92 68 81 71 74 88 69 84 65 73 95 70 78 66 90 73 78 84 70 93 63 79 80 60 87 81 67 86 91 83 77 76 90 70 82 83 82 92 84 81 70 69 72 78 75 78 91 88 66 94 80 85 71 86 74 68 79 62 81 81 55 78 70 75 68 71 77 未分組數(shù)據(jù) —多批數(shù)據(jù)箱線圖 (例題分析 ) 8門課程考試成績的箱線圖 M i n M a x2 5 % 7 5 %M e d i a n v a l u e455565758595105英語經(jīng)濟(jì)數(shù)學(xué)西方經(jīng)濟(jì)學(xué) 市場(chǎng)營銷學(xué)財(cái)務(wù)管理基礎(chǔ)會(huì)計(jì)學(xué)統(tǒng)計(jì)學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)11名學(xué)生 8門課程考試成績的箱線圖 MinMax 25%75% Median value 45 55 65 75 85 95 105 學(xué)生 1 學(xué)生 2 學(xué)生 3 學(xué)生 4 學(xué)生 5 學(xué)生 6 學(xué)生 7 學(xué)生 8 學(xué)生 9 學(xué)生 10 學(xué)生 11 未分組數(shù)據(jù) —多批數(shù)據(jù)箱線圖 (例題分析 ) 例 6 對(duì)某公司雇員數(shù)據(jù),分析性別與工作類型、 性別與是否少數(shù)民族的特征,作出交叉頻數(shù)分布表。 ? ftable(Edata[c(39。GENDER39。,39。JOBCAT39。)]) JOBCAT 經(jīng)理 保管員 服務(wù)員 GENDER f 10 0 206 m 74 27 157 ? ftable(Edata[c(39。GENDER39。,39。MINORITY39。)]) MINORITY Yes No GENDER f 40 176 m 64 194 例 7 對(duì)某公司雇員數(shù)據(jù),分析不同性別、工作類型、少數(shù)民族的收入差異, 作出多批數(shù)據(jù)箱線圖 。 ? boxplot(Edata$SALARY~Edata$GENDER, data = Edata, col = lightgray)。 ? boxplot(Edata$SALARY~Edata$JOBCAT, data = Edata, col = lightgray)。 ? boxplot(Edata$SALARY~Edata$MINORITY, data = Edata, col = lightgray)。 f m20200400006000080000120200Y e s No20200400006000080000120200例 8 對(duì)某公司雇員數(shù)據(jù),分析不同性別、工作類型之間的收入差異, 作出多批數(shù)據(jù)箱線圖 。 ? boxplot(split(Edata$SALARY,list(Edata$JOBCAT,Edata$GENDER)),col = lightgray)。 ? boxplot(split(Edata$SALARY,list(Edata$GENDER,Edata$JOBCAT)),col = lightgray)。 ? 不同性別在不同工作類型上的當(dāng)前工資比較。與工資增長率不同,性別差異在工資水平上的差異十分明顯,男性的工資水平無論在 Clerical還是Manager上都比女性的平均工資水平高。 ? split package:base R Documentation Divide into Groups ? Description: 39。split39。 divides the data in the vector 39。x39。 into the groups defined by 39。f39。. The assignment forms replace values corresponding to such a division. Unsplit reverses the effect of 39。split39。. ? Usage: split(x, f, drop = FALSE, ...) split(x, f, drop = FALSE, ...) value unsplit(value, f, drop = FALSE) ? Arguments: x: vector or data frame containing values to be divided into groups. ? f: a factor in the sense that 39。(f)39。 defines the grouping, or a list of such factors in which case their interaction is used for the grouping. drop: logical indicating if levels that do not occur should be dropped (if 39。f39。 is a 39。factor39。 or a list). value: a list of vectors or data frames patible with a splitting of 39。x39。. Recycling applies if the lengths do not match. ...: further potential arguments passed to methods. ? Details: 39。split39。 and 39。split39。 are generic functions with default and 39。39。 methods. 39。f39。 is recycled as necessary and if the length of 39。x39。 is not a multiple of the length of 39。f39。 a warning is printed. 39。unsplit39。 works only with lists of vectors. The data frame method can also be used to split a matrix into a list of mat