Esimese tunni materjalid
g=9.8
t=4
s=g*t*t/2
s
## [1] 78.4
g=9.8
t=1:4
s=g*t*t/2
s
## [1] 4.9 19.6 44.1 78.4
g=-9.8
t=seq(1, 30, 0.5)
s=g*t*t/2
s
## [1] -4.900 -11.025 -19.600 -30.625 -44.100 -60.025 -78.400
## [8] -99.225 -122.500 -148.225 -176.400 -207.025 -240.100 -275.625
## [15] -313.600 -354.025 -396.900 -442.225 -490.000 -540.225 -592.900
## [22] -648.025 -705.600 -765.625 -828.100 -893.025 -960.400 -1030.225
## [29] -1102.500 -1177.225 -1254.400 -1334.025 -1416.100 -1500.625 -1587.600
## [36] -1677.025 -1768.900 -1863.225 -1960.000 -2059.225 -2160.900 -2265.025
## [43] -2371.600 -2480.625 -2592.100 -2706.025 -2822.400 -2941.225 -3062.500
## [50] -3186.225 -3312.400 -3441.025 -3572.100 -3705.625 -3841.600 -3980.025
## [57] -4120.900 -4264.225 -4410.000
t
## [1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5
## [15] 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5
## [29] 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0 19.5 20.0 20.5 21.0 21.5
## [43] 22.0 22.5 23.0 23.5 24.0 24.5 25.0 25.5 26.0 26.5 27.0 27.5 28.0 28.5
## [57] 29.0 29.5 30.0
t=seq(1, 30, 0.5)
s=g*t*t/2
plot(t, s, type="l")
plot(t, s, type="l", main="Palli kukkumine",
xlab="aeg", ylab="vahemaa")
t=0:5
s=g*t*t/2
barplot(s)
s
## [1] 0.0 -4.9 -19.6 -44.1 -78.4 -122.5
s[1]
## [1] 0
s[2]-s[1]
## [1] -4.9
s2=s[2:6]
s2
## [1] -4.9 -19.6 -44.1 -78.4 -122.5
s3=s[1:5]
s3
## [1] 0.0 -4.9 -19.6 -44.1 -78.4
liikumised=s3-s2
liikumised
## [1] 4.9 14.7 24.5 34.3 44.1
pie(liikumised)
lapsed=read.table("http://www.tlu.ee/~jaagup/andmed/muu/5klass.txt",
header=TRUE, sep=",")
lapsed
## eesnimi pikkus mass sugu
## 1 Juku 170 45 m
## 2 Kati 160 35 n
## 3 Mati 160 72 m
## 4 Madis 165 53 m
## 5 Mati 163 60 m
## 6 Katrin 165 43 n
## 7 Siim 141 38 m
## 8 Martin 159 46 m
## 9 Kadri 164 57 n
## 10 Katariina 148 35 n
## 11 Maria 143 38 n
## 12 Marta 169 55 n
## 13 Madis 156 65 m
## 14 Mihkel 165 69 m
## 15 Tiina 170 38 n
## 16 Miia 145 68 n
## 17 Siim 151 55 m
## 18 Priit 156 63 m
## 19 Kristjan 164 59 m
## 20 Kristi 155 53 n
## 21 Kristiina 158 62 n
## 22 Killu 164 49 n
## 23 Mart 170 69 m
## 24 Kert 143 36 m
## 25 Gert 152 67 m
## 26 Lauri 156 53 m
## 27 Moonika 164 58 n
## 28 Jaanika 165 59 n
## 29 Jaanus 164 63 m
## 30 Jaan 162 65 m
lapsed$pikkus
## [1] 170 160 160 165 163 165 141 159 164 148 143 169 156 165 170 145 151
## [18] 156 164 155 158 164 170 143 152 156 164 165 164 162
mean(lapsed$pikkus)
## [1] 158.9
lapsed$pikkus-mean(lapsed$pikkus)
## [1] 11.1 1.1 1.1 6.1 4.1 6.1 -17.9 0.1 5.1 -10.9 -15.9
## [12] 10.1 -2.9 6.1 11.1 -13.9 -7.9 -2.9 5.1 -3.9 -0.9 5.1
## [23] 11.1 -15.9 -6.9 -2.9 5.1 6.1 5.1 3.1
round(lapsed$pikkus-mean(lapsed$pikkus))
## [1] 11 1 1 6 4 6 -18 0 5 -11 -16 10 -3 6 11 -14 -8
## [18] -3 5 -4 -1 5 11 -16 -7 -3 5 6 5 3
round(sort(lapsed$pikkus)-mean(lapsed$pikkus))
## [1] -18 -16 -16 -14 -11 -8 -7 -4 -3 -3 -3 -1 0 1 1 3 4
## [18] 5 5 5 5 5 6 6 6 6 10 11 11 11
table(round(sort(lapsed$pikkus)-mean(lapsed$pikkus)))
##
## -18 -16 -14 -11 -8 -7 -4 -3 -1 0 1 3 4 5 6 10 11
## 1 2 1 1 1 1 1 3 1 1 2 1 1 5 4 1 3
table(lapsed$sugu)
##
## m n
## 17 13
table(lapsed$sugu, lapsed$pikkus>160)
##
## FALSE TRUE
## m 9 8
## n 6 7
barplot(table(lapsed$sugu, lapsed$pikkus>160))
barplot(table(lapsed$sugu, lapsed$pikkus>160),
xlab="pikkus>160", ylab="laste arv", beside = TRUE,
main="Sagedusjaotus vastavalt pikkustele")
hist(lapsed$pikkus)
hist(lapsed$pikkus, breaks=seq(140, 180, 8), main="Pikkuste histogramm"
, ylab="sagedus")
plot(lapsed$pikkus, lapsed$mass)
plot(lapsed$pikkus, lapsed$mass, col=ifelse(lapsed$sugu=="m", "blue", "red"))
plot(lapsed$pikkus, lapsed$mass, type="n")
text(lapsed$pikkus, lapsed$mass, lapsed$eesnimi,
col=ifelse(lapsed$sugu=="m", "blue", "red"), cex=0.7) #fondi suurus
abline(v=mean(lapsed$pikkus), col="gray")
#Lisage horisontaaljoon laste keskmise massiga
abline(h=mean(lapsed$mass), lty=2)
abline(lm(lapsed$mass~lapsed$pikkus))