Sie sind auf Seite 1von 13

>

Bl.gr.dat=factor(c("O","O","A","B","A","O","A","A","A","O","B","O","B","O","O","A","O"
,"O
+
","A","A","A","A","AB","A","B","A","A","O","O","A","O","O","A","A","A","O","A","O","O"
,
+ "AB"), levels=c("O","A","B","AB"))
> table(Bl.gr.dat)
Bl.gr.dat
O A B AB
15 18 4 2
> cbind(table(Bl.gr.dat))
[,1]
O

15

18

AB

> pie(table(Bl.gr.dat),main="Pie-Chart of Employee Blood Groups")


> ?pie
starting httpd help server ... done
> barplot(table(Bl.gr.dat),main="Pie-Chart of Employee Blood Groups",xlab="Blood
+ Groups",ylab="Number of Employees")
> barplot(table(Bl.gr.dat),main="Pie-Chart of Employee Blood Groups",xlab="Blood
+ Groups",ylab="Number of Employees",ylim=c(0,25))
> barplot(table(Bl.gr.dat),main="Pie-Chart of Employee Blood Groups",xlab="Blood
+ Groups",ylab="Number of Employees",ylim=c(0,5))
> barplot(table(Bl.gr.dat),main="Pie-Chart of Employee Blood Groups",xlab="Blood
+ Groups",ylab="Number of Employees",ylim=c(0,25))

>
age=c(34,67,40,72,37,33,42,62,49,32,52,40,31,19,68,55,57,54,37,32,54,38,20,50,5
6,48,35,52,29,
+
56,68,65,45,44,54,39,29,56,43,42,22,30,26,20,48,29,34,27,40,28,45,21,42,38,29,2
6,62,35,28,24,
+
44,46,39,29,27,40,22,38,42,39,26,48,39,25,34,56,31,60,32,24,51,69,28,27,38,56,3
6,25,46,50,36,
+ 58,39,57,55,42,49,38,49,36,48,44)
> age
[1] 34 67 40 72 37 33 42 62 49 32 52 40 31 19 68 55 57 54 37 32 54 38 20 50 56
48 35 52 29 56 68 65 45 44 54 39 29 56 43 42 22 30 26 20 48 29 34 27 40 28 45
21 42 38
[55] 29 26 62 35 28 24 44 46 39 29 27 40 22 38 42 39 26 48 39 25 34 56 31 60 32
24 51 69 28 27 38 56 36 25 46 50 36 58 39 57 55 42 49 38 49 36 48 44
> range(age)
[1] 19 72
> breaks=seq(15,75,5)
>
> breaks
[1] 15 20 25 30 35 40 45 50 55 60 65 70 75
> age.cut=cut(age, breaks, right=FALSE)
> age.cut
[1] [30,35) [65,70) [40,45) [70,75) [35,40) [30,35) [40,45) [60,65) [45,50)
[10] [30,35) [50,55) [40,45) [30,35) [15,20) [65,70) [55,60) [55,60) [50,55)
[19] [35,40) [30,35) [50,55) [35,40) [20,25) [50,55) [55,60) [45,50) [35,40)
[28] [50,55) [25,30) [55,60) [65,70) [65,70) [45,50) [40,45) [50,55) [35,40)
[37] [25,30) [55,60) [40,45) [40,45) [20,25) [30,35) [25,30) [20,25) [45,50)
[46] [25,30) [30,35) [25,30) [40,45) [25,30) [45,50) [20,25) [40,45) [35,40)

[55] [25,30) [25,30) [60,65) [35,40) [25,30) [20,25) [40,45) [45,50) [35,40)
[64] [25,30) [25,30) [40,45) [20,25) [35,40) [40,45) [35,40) [25,30) [45,50)
[73] [35,40) [25,30) [30,35) [55,60) [30,35) [60,65) [30,35) [20,25) [50,55)
[82] [65,70) [25,30) [25,30) [35,40) [55,60) [35,40) [25,30) [45,50) [50,55)
[91] [35,40) [55,60) [35,40) [55,60) [55,60) [40,45) [45,50) [35,40) [45,50)
[100] [35,40) [45,50) [40,45)
12 Levels: [15,20) [20,25) [25,30) [30,35) [35,40) [40,45) [45,50) ... [70,75)
> age.cut=cut(age, breaks, right=True)
Error in paste0(if (right) "(" else "[", ch.br[-nb], ",", ch.br[-1L], :
object 'True' not found
> frequency=table(age.cut)
>
> frequency
age.cut
[15,20) [20,25) [25,30) [30,35) [35,40) [40,45) [45,50) [50,55) [55,60) [60,65)
1

16

[65,70) [70,75)
5

> cbind(frequency)
frequency
[15,20)

[20,25)

[25,30)

16

[30,35)

10

[35,40)

17

[40,45)

13

10

17

13

11

10

[45,50)

11

[50,55)

[55,60)

10

[60,65)

[65,70)

[70,75)

> Relative.Frequency=frequency/length(age)
> cbind(Relative.Frequency)
Relative.Frequency
[15,20)

0.009803922

[20,25)

0.068627451

[25,30)

0.156862745

[30,35)

0.098039216

[35,40)

0.166666667

[40,45)

0.127450980

[45,50)

0.107843137

[50,55)

0.078431373

[55,60)

0.098039216

[60,65)

0.029411765

[65,70)

0.049019608

[70,75)

0.009803922

> Cumulative.Frequency=cumsum(frequency)
> cbind(Cumulative.Frequency)
Cumulative.Frequency
[15,20)

[20,25)

[25,30)

24

[30,35)

34

[35,40)

51

[40,45)

64

[45,50)

75

[50,55)

83

[55,60)

93

[60,65)

96

[65,70)

101

[70,75)

102

> cbind(frequency,Relative.Frequency,Cumulative.Frequency)
frequency Relative.Frequency Cumulative.Frequency
[15,20)

0.009803922

[20,25)

0.068627451

[25,30)

16

0.156862745

24

[30,35)

10

0.098039216

34

[35,40)

17

0.166666667

51

[40,45)

13

0.127450980

64

[45,50)

11

0.107843137

75

[50,55)

[55,60)

10

[60,65)

0.029411765

96

[65,70)

0.049019608

101

[70,75)

0.009803922

102

0.078431373
0.098039216

> hist(age)
> hist(age,breaks=seq(15,75,10))

83
93

> hist(age,breaks=c(15,25,35,45,55,65,75)
+ hist(age,breaks=c(15,25,35,45,55,65,75))
Error: unexpected symbol in:
"hist(age,breaks=c(15,25,35,45,55,65,75)
hist"
> hist(age,breaks=c(15,25,35,45,55,65,75))
>
VarSal=factor(c(0.11,0.17,0.11,0.15,0.10,0.11,0.21,0.20,0.14,0.14,0.23,0.25,0.07,0.
09,0.10,0.10,0.19,0.11,0.19,
+
0.17,0.12,0.12,0.12,0.10,0.11,0.13,0.10,0.09,0.11,0.15,0.13,0.10,0.18,0.09,0.07,0.0
8,0.06,0.08,
+
VarSal=factor(c(0.11,0.17,0.11,0.15,0.10,0.11,0.21,0.20,0.14,0.14,0.23,0.25,0.07,0.
09,0.10,0.10,0.19,0.11,0.19,
+
+
s1=c(0.11,0.17,0.11,0.15,0.10,0.11,0.21,0.20,0.14,0.14,0.23,0.25,0.07,0.09,0.10,0.
10,0.19,0.11,0.19,)
+
0.17,0.12,0.12,0.12,0.10,0.11,0.13,0.10,0.09,0.11,0.15,0.13,0.10,0.18,0.09,0.07,0.0
8,0.06,0.08,
Error: unexpected numeric constant in:
"s1=c(0.11,0.17,0.11,0.15,0.10,0.11,0.21,0.20,0.14,0.14,0.23,0.25,0.07,0.09,0.10,0.
10,0.19,0.11,0.19,)
0.17"
> 0.05,0.07,0.08,0.08,0.07,0.09,0.06,0.07,0.08,0.07,0.07,0.07,0.08,0.06,0.07,0.06
Error: unexpected ',' in "0.05,"
>
s1=c(0.11,0.17,0.11,0.15,0.10,0.11,0.21,0.20,0.14,0.14,0.23,0.25,0.07,0.09,0.10,0.
10,0.19,0.11,0.19,

+
0.17,0.12,0.12,0.12,0.10,0.11,0.13,0.10,0.09,0.11,0.15,0.13,0.10,0.18,0.09,0.07,0.0
8,0.06,0.08,
+ 0.05,0.07,0.08,0.08,0.07,0.09,0.06,0.07,0.08,0.07,0.07,0.07,0.08,0.06,0.07,0.06)
> range(s1)
[1] 0.05 0.25
> s1
[1] 0.11 0.17 0.11 0.15 0.10 0.11 0.21 0.20 0.14 0.14 0.23 0.25 0.07 0.09 0.10
[16] 0.10 0.19 0.11 0.19 0.17 0.12 0.12 0.12 0.10 0.11 0.13 0.10 0.09 0.11 0.15
[31] 0.13 0.10 0.18 0.09 0.07 0.08 0.06 0.08 0.05 0.07 0.08 0.08 0.07 0.09 0.06
[46] 0.07 0.08 0.07 0.07 0.07 0.08 0.06 0.07 0.06
> breaks=seq(0.00,0.25,5)
> breaks
[1] 0
> breaks=seq(0.00,0.30,0.05)
> breaks
[1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30
> s1.cut=cut(s1,breaks,right=False)
Error in paste0(if (right) "(" else "[", ch.br[-nb], ",", ch.br[-1L], :
object 'False' not found
> s1.cut=cut(s1,breaks,right=FALSE)
> s1.cut
[1] [0.1,0.15) [0.15,0.2) [0.1,0.15) [0.1,0.15) [0.1,0.15) [0.1,0.15)
[7] [0.2,0.25) [0.2,0.25) [0.1,0.15) [0.1,0.15) [0.2,0.25) [0.25,0.3)
[13] [0.05,0.1) [0.05,0.1) [0.1,0.15) [0.1,0.15) [0.15,0.2) [0.1,0.15)
[19] [0.15,0.2) [0.15,0.2) [0.1,0.15) [0.1,0.15) [0.1,0.15) [0.1,0.15)
[25] [0.1,0.15) [0.1,0.15) [0.1,0.15) [0.05,0.1) [0.1,0.15) [0.1,0.15)

[31] [0.1,0.15) [0.1,0.15) [0.15,0.2) [0.05,0.1) [0.05,0.1) [0.05,0.1)


[37] [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1)
[43] [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1)
[49] [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1)
Levels: [0,0.05) [0.05,0.1) [0.1,0.15) [0.15,0.2) [0.2,0.25) [0.25,0.3)
> frequency=table(s1.cut)
> s1.cut
[1] [0.1,0.15) [0.15,0.2) [0.1,0.15) [0.1,0.15) [0.1,0.15) [0.1,0.15)
[7] [0.2,0.25) [0.2,0.25) [0.1,0.15) [0.1,0.15) [0.2,0.25) [0.25,0.3)
[13] [0.05,0.1) [0.05,0.1) [0.1,0.15) [0.1,0.15) [0.15,0.2) [0.1,0.15)
[19] [0.15,0.2) [0.15,0.2) [0.1,0.15) [0.1,0.15) [0.1,0.15) [0.1,0.15)
[25] [0.1,0.15) [0.1,0.15) [0.1,0.15) [0.05,0.1) [0.1,0.15) [0.1,0.15)
[31] [0.1,0.15) [0.1,0.15) [0.15,0.2) [0.05,0.1) [0.05,0.1) [0.05,0.1)
[37] [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1)
[43] [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1)
[49] [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1) [0.05,0.1)
Levels: [0,0.05) [0.05,0.1) [0.1,0.15) [0.15,0.2) [0.2,0.25) [0.25,0.3)
> frequency
S1.cut
[0,0.05) [0.05,0.1) [0.1,0.15) [0.15,0.2) [0.2,0.25) [0.25,0.3)
0

24

21

> relative.frequency=frequency/length(age)
> cbind(Relative.Frequency)
Relative.Frequency
[15,20)

0.009803922

[20,25)

0.068627451

[25,30)

0.156862745

[30,35)

0.098039216

[35,40)

0.166666667

[40,45)

0.127450980

[45,50)

0.107843137

[50,55)

0.078431373

[55,60)

0.098039216

[60,65)

0.029411765

[65,70)

0.049019608

[70,75)

0.009803922

> Cumulative.Frequency=cumsum(frequency)
>
cbind(Cumulative.Frequency)cbind(frequency,Relative.Frequency,Cumulative.Freque
ncy)
Error: unexpected symbol in "cbind(Cumulative.Frequency)cbind"
>
>
cbind(Cumulative.Frequency)cbind(frequency,Relative.Frequency,Cumulative.Freque
ncy
Error: unexpected symbol in "cbind(Cumulative.Frequency)cbind"
> cbind(Cumulative.Frequency)
Cumulative.Frequency
[0,0.05)

[0.05,0.1)

24

[0.1,0.15)

45

[0.15,0.2)

50

[0.2,0.25)

53

[0.25,0.3)

54

>
s1=c(0.11,0.17,0.11,0.15,0.10,0.11,0.21,0.20,0.14,0.14,0.23,0.25,0.07,0.09,0.10,0.
10,0.19,0.11,0.19,
+
0.17,0.12,0.12,0.12,0.10,0.11,0.13,0.10,0.09,0.11,0.15,0.13,0.10,0.18,0.09,0.07,0.0
8,0.06,0.08,
+ 0.05,0.07,0.08,0.08,0.07,0.09,0.06,0.07,0.08,0.07,0.07,0.07,0.08,0.06,0.07,0.06)
> range(s1)
[1] 0.05 0.25
> breaks=seq(0.025,0.275,.05)
> breaks
[1] 0.025 0.075 0.125 0.175 0.225 0.275
> s1.cut=cut(s1,breaks,right=FALSE)
> s1.cut
[1] [0.075,0.125) [0.125,0.175) [0.075,0.125) [0.125,0.175) [0.075,0.125)
[6] [0.075,0.125) [0.175,0.225) [0.175,0.225) [0.125,0.175) [0.125,0.175)
[11] [0.225,0.275) [0.225,0.275) [0.025,0.075) [0.075,0.125) [0.075,0.125)
[16] [0.075,0.125) [0.175,0.225) [0.075,0.125) [0.175,0.225) [0.125,0.175)
[21] [0.075,0.125) [0.075,0.125) [0.075,0.125) [0.075,0.125) [0.075,0.125)
[26] [0.125,0.175) [0.075,0.125) [0.075,0.125) [0.075,0.125) [0.125,0.175)
[31] [0.125,0.175) [0.075,0.125) [0.175,0.225) [0.075,0.125) [0.025,0.075)
[36] [0.075,0.125) [0.025,0.075) [0.075,0.125) [0.025,0.075) [0.025,0.075)
[41] [0.075,0.125) [0.075,0.125) [0.025,0.075) [0.075,0.125) [0.025,0.075)
[46] [0.025,0.075) [0.075,0.125) [0.025,0.075) [0.025,0.075) [0.025,0.075)
[51] [0.075,0.125) [0.025,0.075) [0.025,0.075) [0.025,0.075)
5 Levels: [0.025,0.075) [0.075,0.125) [0.125,0.175) ... [0.225,0.275)
>
> frequency=table(s1.cut)

> frequency
s1.cut
[0.025,0.075) [0.075,0.125) [0.125,0.175) [0.175,0.225) [0.225,0.275)
14

25

> cbind(frequency)
frequency
[0.025,0.075)

14

[0.075,0.125)

25

[0.125,0.175)

[0.175,0.225)

[0.225,0.275)

> Relative.Frequency=frequency/length(age)
> Cumulative.Frequency=cumsum(frequency)
> cbind(frequency,Relative.Frequency,Cumulative.Frequency)
frequency Relative.Frequency Cumulative.Frequency
[0.025,0.075)

14

0.13725490

14

[0.075,0.125)

25

0.24509804

39

[0.125,0.175)

0.07843137

47

[0.175,0.225)

0.04901961

52

[0.225,0.275)

0.01960784

54

> hist(age)
> hist(s1)
> breaks=seq(0.025,0.275,.05)
> hist(s1,breaks=seq(0.025,0.275,.05))
> mean(age)
[1] 41.2549

> median(age)
[1] 39.5
>
Bl.gr.dat=factor(c("O","O","A","B","A","O","A","A","A","O","B","O","B","O","O","A","O"
,"O
+
","A","A","A","A","AB","A","B","A","A","O","O","A","O","O","A","A","A","O","A","O","O"
,
+ "AB"), levels=c("O","A","B","AB"))
> table(Bl.gr.dat)
Bl.gr.dat
O A B AB
15 18 4 2
> Bl.gr=table(as.vector(Bl.gr.dat))
> names(Bl.gr)[Bl.gr == max(Bl.gr)]
[1] "A"
> summary(age)
Min. 1st Qu. Median

Mean 3rd Qu.

Max.

19.00 31.00 39.50 41.25 50.00 72.00


> boxplot(age)
> IQR(age)
[1] 19
> 1.5*IQR(age)
[1] 28.5
> score=c(28,22,26,29,21,23,24)
> boxplot(score)
> score=(28,22,26,29,21,23,24,50)
Error: unexpected ',' in "score=(28,"

> score=c(28,22,26,29,21,23,24,50)
> boxplot(score)
> sd(age)
[1] 12.82686
> score=c(28,22,26,29,21,23,24)
> sd(score)
[1] 3.039424
> score=c(score=c(28,22,26,29,21,23,24,25)
+ sd(score)
Error: unexpected symbol in:
"score=c(score=c(28,22,26,29,21,23,24,25)
sd"
> score=c(28,22,26,29,21,23,24,50)
> sd(score)
[1] 9.372262
> quantile(score,0.8)
80%
28.6
> quantile(score,c(.7,.8,.9))
70% 80% 90%
27.8 28.6 35.3
> ?sd
>

Das könnte Ihnen auch gefallen