forked from DanielaGawehns/DementiaPhysicalActivity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemographics.R
63 lines (41 loc) · 2.03 KB
/
Demographics.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
#Extract Summary Statistics on Age, Gender, Walking Aids for Participants in 2019 and 2021
##
#library(haven)
#PatientVraaglijst_2018 <- read_dta("DataMedloADL/data set_client vragenlijlst 2018_def1.dta")
#From MEDLO: DOB and GESLACHT ( [, 3:4])
install.packages("eeptools") # Install eeptools package
library("eeptools")
# Medlo_2019 [,4] date Data Collection
my_df <- as.data.frame(Medlo_2019 [,1:10])
ageAtCollection19<- numeric()
for (i in 1:nrow(Medlo_2019)) {
date_today <- as.Date(my_df [i,4], format = "%d/%m/%Y") #Date Data Collection
x_birth <- as.Date(as.character(Medlo_2019 [i,10]), format = "%d/%m/%Y")
x_age <- age_calc(x_birth, # Convert birth to age
date_today,
units = "years")
ageAtCollection19[i] <- floor(x_age)
}
###################
# Medlo_2011 [,4] date Data Collection
my_df <- as.data.frame(Medlo_2021 [,1:10])
ageAtCollection21<- numeric()
for (i in 1:nrow(Medlo_2021)) {
date_today <- as.Date(my_df [i,4], format = "%d/%m/%Y") #Date Data Collection
x_birth <- as.Date(as.character(Medlo_2021 [i,10]), format = "%d/%m/%Y")
x_age <- age_calc(x_birth, # Convert birth to age
date_today,
units = "years")
ageAtCollection21[i] <- floor(x_age)
}
#########################
CodeAgeGeslacht21<- cbind(codebw = Medlo_2021 [,8],Age = ageAtCollection21 , Geslacht = Medlo_2021 [,9]) [!duplicated(Medlo_2021 [,8]), ]
CodeAgeGeslacht19<- cbind(codebw= Medlo_2019 [,8],Age = ageAtCollection19 , Geslacht = Medlo_2019 [,9]) [!duplicated(Medlo_2019 [,8]), ]
colnames(CodeAgeGeslacht19)<- c("codebw", "Age", "geslacht")
range(rbind(CodeAgeGeslacht19, CodeAgeGeslacht21) [,"Age"])
mean(rbind(CodeAgeGeslacht19, CodeAgeGeslacht21) [,"Age"])
sd(rbind(CodeAgeGeslacht19, CodeAgeGeslacht21) [,"Age"])
rbind(CodeAgeGeslacht19, CodeAgeGeslacht21) [,"geslacht"] #1 = Female, 0 = Male
length(rbind(CodeAgeGeslacht19, CodeAgeGeslacht21) [,"geslacht"] ) #24 in total, 2 male
#######################
nrow(CodeAgeGeslacht21)