Вы находитесь на странице: 1из 4

R version 3.2.

0 (2015-04-16) -- "Full of Ingredients"


Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Previously saved workspace restored]
>
>
>
>
>

produksi=c(1.4,1.3,1.6,1.5,1.5,1.4,1.2,1.3,1.2,1.1,1,0.9)
perlakuan=c(rep("u1",4),rep("u2",4),rep("u3",4),rep("u4",4))
perlakuan=c(rep("p1",4),rep("p2",4),rep("p3",4))
ujihormon=data.frame(perlakuan,produksi)
ujihormon
perlakuan produksi
1
p1
1.4
2
p1
1.3
3
p1
1.6
4
p1
1.5
5
p2
1.5
6
p2
1.4
7
p2
1.2
8
p2
1.3
9
p3
1.2
10
p3
1.1
11
p3
1.0
12
p3
0.9
> tapply(produksi,perlakuan,mean)
p1
p2
p3
1.45 1.35 1.05
> tapply(produksi,perlakuan,min)
p1 p2 p3
1.3 1.2 0.9
> tapply(produksi,perlakuan,max)
p1 p2 p3
1.6 1.5 1.2
> tapply(produksi,perlakuan,var)
p1
p2
p3
0.01666667 0.01666667 0.01666667
> tapply(produksi,perlakuan,mid)
Error in tapply(produksi, perlakuan, mid) : object 'mid' not found
> tapply(produksi,perlakuan,length)
p1 p2 p3
4 4 4

> boxplot(produksi~perlakuan)
> oneway.test(produksi~perlakuan)
One-way analysis of means (not assuming equal variances)
data: produksi and perlakuan
F = 9.36, num df = 2, denom df = 6, p-value = 0.0143
> summary(aov(produksi~perlakuan))
Df Sum Sq Mean Sq F value Pr(>F)
perlakuan
2 0.3467 0.17333
10.4 0.00457 **
Residuals
9 0.1500 0.01667
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
> TukeyHSD(aov.out)
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = x ~ y, data = InsectSprays)
$y
B-A
C-A
D-A
E-A
F-A
C-B
D-B
E-B
F-B
D-C
E-C
F-C
E-D
F-D
F-E

diff
0.8333333
-12.4166667
-9.5833333
-11.0000000
2.1666667
-13.2500000
-10.4166667
-11.8333333
1.3333333
2.8333333
1.4166667
14.5833333
-1.4166667
11.7500000
13.1666667

lwr
-3.866075
-17.116075
-14.282742
-15.699409
-2.532742
-17.949409
-15.116075
-16.532742
-3.366075
-1.866075
-3.282742
9.883925
-6.116075
7.050591
8.467258

upr
5.532742
-7.717258
-4.883925
-6.300591
6.866075
-8.550591
-5.717258
-7.133925
6.032742
7.532742
6.116075
19.282742
3.282742
16.449409
17.866075

p adj
0.9951810
0.0000000
0.0000014
0.0000000
0.7542147
0.0000000
0.0000002
0.0000000
0.9603075
0.4920707
0.9488669
0.0000000
0.9488669
0.0000000
0.0000000

> x=perlakuan$count
Error in perlakuan$count : $ operator is invalid for atomic vectors
> x=ujihormon$produksi
> y=ujihormon$perlakuan
> x
[1] 1.4 1.3 1.6 1.5 1.5 1.4 1.2 1.3 1.2 1.1 1.0 0.9
> y
[1] p1 p1 p1 p1 p2 p2 p2 p2 p3 p3 p3 p3
Levels: p1 p2 p3
> summary(x)
Min. 1st Qu. Median
Mean 3rd Qu.
Max.
0.900
1.175
1.300
1.283
1.425
1.600
> mean(x[y==p1])
Error in mean(x[y == p1]) : object 'p1' not found
> mean(x[y=="p1"])
[1] 1.45

> x
[1] 1.4 1.3 1.6 1.5 1.5 1.4 1.2 1.3 1.2 1.1 1.0 0.9
> y
[1] p1 p1 p1 p1 p2 p2 p2 p2 p3 p3 p3 p3
Levels: p1 p2 p3
> xb1=mean(x[y=="p1"]
+ )
> xb2=mean(x[y=="p2"])
> xb3=mean(x[y=="p3"])
> xb=c(xb1,xb2,xb3)
> xb
[1] 1.45 1.35 1.05
> tapply(x,y,mean)
p1
p2
p3
1.45 1.35 1.05
> XB=tapply(x,y,mean)
> XB
p1
p2
p3
1.45 1.35 1.05
> VAR=tapply(x,y,var)
> VAR
p1
p2
p3
0.01666667 0.01666667 0.01666667
> MIN=tapply(x,y,min)
> MIN
p1 p2 p3
1.3 1.2 0.9
> MAX=(tapply(x,y,max)
+ )
> MAX
p1 p2 p3
1.6 1.5 1.2
> aov.out=aov(x~y,ujihormon)
> summary(aov,out)
Error in object[[i]] : object of type 'closure' is not subsettable
> summary(aov.out)
Df Sum Sq Mean Sq F value Pr(>F)
y
2 0.3467 0.17333
10.4 0.00457 **
Residuals
9 0.1500 0.01667
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
> TuckyeyHSD(aov.out)
Error: could not find function "TuckyeyHSD"
> TukeyHSD(aov.out)
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = x ~ y, data = ujihormon)
$y
diff
lwr
upr
p adj
p2-p1 -0.1 -0.3548741 0.15487408 0.5402482
p3-p1 -0.4 -0.6548741 -0.14512592 0.0045122
p3-p2 -0.3 -0.5548741 -0.04512592 0.0231730

> TukeyHSD(aov.out)

Вам также может понравиться