19
1 IST 1051 Computational Tools for Statistics I 4DEÜ, Department of Statistics Sorting Data Minitab You can sort one or more columns of data according to values in the associated column(s) you select. Sorting alphabetizes or numerically orders the data and carries along the associated columns. You can sort in ascending or descending order, and you can specify whether the sorted data should be stored in the original columns, other columns you specify, or in a new worksheet. 2

Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

1

IST 1051Computational Tools for Statistics I

‐4‐

DEÜ, Department of Statistics

Sorting Data ‐Minitab• You can sort one or more columns of data

according to values in the associatedcolumn(s) you select.

• Sorting alphabetizes or numerically orders thedata and carries along the associatedcolumns.

• You can sort in ascending or descendingorder, and you can specify whether thesorted data should be stored in the originalcolumns, other columns you specify, or in anew worksheet.

2

Page 2: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

2

Sorting Data ‐Minitab

3

Sort

4

Page 3: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

3

Example• Open worksheet ABCSales.MTW

5

Example

6

Page 4: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

4

Example

7

ABCSales.mtw

8İST 1051 - Lecture Notes

Page 5: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

5

ABCSales.mtw• Sort Index, Month and Sales data with respect to

Sales in ascending order

9İST 1051 - Lecture Notes

ABCSales.mtw• Sort Index, Month and Sales data with respect to

Sales in ascending order

MTB > sort c1 c2 c3 c7 c8 c9;SUBC> by c3.

10İST 1051 - Lecture Notes

Page 6: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

6

ABCSales.mtw• Sort Index, Month and Sales data with respect to

Sales in descending order

11İST 1051 - Lecture Notes

ABCSales.mtw• Sort Index, Month and Sales data with respect to

Sales in descending order

MTB > sort c1 c2 c3 c7 c8 c9;SUBC> by c3;SUBC> descending c3.

12İST 1051 - Lecture Notes

Page 7: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

7

Example• Open "Bears" Data

13İST 1051 - Lecture Notes

Bears.mtw• Sort Age, Sex and Weight data with respect to Age and

Sex in descending and ascending order respectively

14İST 1051 - Lecture Notes

Page 8: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

8

Bears.mtw• Sort Age, Sex and Weight data with respect to Age

and Sex in descending and ascending orderrespectively

MTB > sort c2 c4 c10 c14 c15 c16;SUBC> by c2 c4;SUBC> descending c2.

15İST 1051 - Lecture Notes

SPSS‐SORTING CASES• To sort the data file based on another variable from

the IBM SPSS main menu select Data ➔ Sort Cases

• This produces the Sort Cases dialog window

16İST 1051 - Lecture Notes

Page 9: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

9

SPSS‐SORTING CASES

• File Open Data• (C:\Program Files\...\SPSS\...\Samples\ accidents.sav

17İST 1051 - Lecture Notes

SPSS‐SORTING CASES• Data ➔ Sort Cases

18İST 1051 - Lecture Notes

Page 10: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

10

SPSS‐SORTING CASES

19İST 1051 - Lecture Notes

SPSS‐SORTING CASES

20İST 1051 - Lecture Notes

Page 11: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

11

SPSS‐SORTING CASES

21İST 1051 - Lecture Notes

R – sort function

• sort(x, decreasing = FALSE)

• Sort a vector into ascending or descending order.

>x<-c(3,5,12,6,7,10,7,2,4,9,3,2)>sort(x)[1] 2 2 3 3 4 5 6 7 7 9 10 12

22İST 1051 - Lecture Notes

Page 12: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

12

How can you sort the values in decreasing order?

> sort(x,decreasing=TRUE)

[1] 12 10 9 7 7 6 5 4 3 3 2 2

23İST 1051 - Lecture Notes

R – sort function

• What is the sum of the three largest values in x?

> sum(sort(x,T)[1:3])

[1] 31

24İST 1051 - Lecture Notes

R – sort function

Page 13: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

13

Frequencies

Example: Shippingdata• Open WorksheetMeet MINITAB/Shippingdata.MTW

25İST 1051 - Lecture Notes

Minitab ‐ Tally• Use to display counts, cumulative counts, percents,

and cumulative percents for each specified variable.

26İST 1051 - Lecture Notes

Page 14: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

14

Tally

27İST 1051 - Lecture Notes

Tally

28İST 1051 - Lecture Notes

Page 15: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

15

Tally

29İST 1051 - Lecture Notes

Tally

30İST 1051 - Lecture Notes

Page 16: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

16

Tally Subcommands• COUNTS Displays the count for each category

• CUMCOUNTS Displays the cumulative counts for eachcategory

• PERCENTS Displays what percentage of the whole is accounted for by each category

• CUMPERCENTS Displays the cumulative percents for each category

• ALL Displays counts, cumulative counts, percents, and cumulative percents for each category

31İST 1051 - Lecture Notes

TallyMTB > tally c1 c5;SUBC> counts;SUBC> percents.

32İST 1051 - Lecture Notes

Page 17: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

17

SPSS‐FREQUENCIES

• File Open Data• (C:\Program Files\...\SPSS\...\Samples\ bankloan.sav

33İST 1051 - Lecture Notes

SPSS‐FREQUENCIES• Analyze Descriptive Statistics Frequencies

34İST 1051 - Lecture Notes

Page 18: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

18

SPSS‐FREQUENCIES

35İST 1051 - Lecture Notes

R – table() function

> x<-c(rep("A",5),rep("B",8),rep("C",3),rep("D",10))> x[1] "A" "A" "A" "A" "A" "B" "B" "B" "B" "B" "B" "B" "B" "C" "C" "C" "D" "D" "D"[20] "D" "D" "D" "D" "D" "D" "D"

> table(x)xA B C D 5 8 3 10

36İST 1051 - Lecture Notes – Engin Yıldıztepe

Page 19: Computational Tools for Statistics I 4 - DEUkisi.deu.edu.tr/engin.yildiztepe/dl/ist1051/IST1051_2017_04.pdf · Computational Tools for Statistics I ‐4‐ DEÜ, Department of Statistics

19

R > LETTERS[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S"

[20] "T" "U" "V" "W" "X" "Y" "Z"

> letters[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"

[20] "t" "u" "v" "w" "x" "y" "z"

37İST 1051 - Lecture Notes

R – table() function

> x<-rep(LETTERS[1:5],c(3,5,6,7,9))> x[1] "A" "A" "A" "B" "B" "B" "B" "B" "C" "C" "C" "C" "C" "C" "D" "D" "D" "D" "D"

[20] "D" "D" "E" "E" "E" "E" "E" "E" "E" "E" "E"

> table(x)xA B C D E 3 5 6 7 9

38İST 1051 - Lecture Notes