-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathh2-oefening-1.R
61 lines (40 loc) · 1.79 KB
/
h2-oefening-1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# install.packages("RcmdrMisc")
library(car)
library(RcmdrMisc)
# install.packages("readxl")
library(readxl)
# volk <- read_excel("data/bevolkingsgegevens.xlsx", sheet = "bevolkingsgegevens")
volk <- readXL("data/bevolkingsgegevens.xlsx", rownames=FALSE , header=TRUE , na="", sheet="bevolkingsgegevens", stringsAsFactors=TRUE)
mean_geboorte <- mean(volk$Bevolkingsgroei)
mean_sterfte <- mean(volk$Overledenen)
mean_scheiding <- mean(volk$Echtscheiding)
# numSummary(Bevolkingsgegevens[,c("Echtscheiding", "Levendgeborenen", "Overledenen")], statistics=c("mean"))
sd_immigratie <- sd(volk$Immigratie)
sd_emigratie <- sd(volk$Emigratie)
# numSummary(Bevolkingsgegevens[,c("Emigratie", "Immigratie")], statistics=c("sd"))
# install.packages("raster")
library(sp)
library(raster)
cv_huwelijksontbinxding <- cv(volk$Huwelijksontbindingen)
cv_echtscheidingen <- cv(volk$Echtscheiding)
# numSummary(Bevolkingsgegevens[,c("Echtscheiding", "Huwelijksontbindingen")],statistics=c("cv"))
maanden <- seq(1,200,6)
maandlabels <- volk$Periode[maanden]
plot(volk$Bevolking, type = "l", xaxt="n", xlab = "")
axis(1, at=maanden, labels=maandlabels,las=3)
em <- volk$Emigratie
im <- volk$Immigratie
plot(em, type = "l", col= "red", xlab = "", xaxt = "n", main = "Migratie")
lines(im, type = "l", col = "blue")
axis(1, at=maanden, labels=maandlabels,las=3)
# with(Bevolkingsgegevens, lineplot(1:200, Emigratie, Immigratie))
# Mean average
ma <- function(x,n=40){filter(x,rep(1/n,n), sides=2)}
me <- ma(volk$Emigratie)
mi <- ma(volk$Immigratie)
min <- min(c(me, mi), na.rm = TRUE)
max <- max(c(me, mi), na.rm = TRUE)
plot(me, type = "l", col= "red", xlab = "", xaxt = "n", main = "Migratie", ylim = c(min, max))
lines(mi, type = "l", col = "blue")
lines(me~mi, type = "l", col = "green")
axis(1, at=maanden, labels=maandlabels,las=3)