data<-haven::read_sav("C:/Users/aklwin/OneDrive/Documents/R/Data/Data.sav")
data2<-data %>% filter(CHD6t18==1)
# Include only households with children 6 to 18 year old
table(data2$CHD6t18ALTEDU)
##
## 1 2 3
## 19 13 70
# tabulate the above households with their children for access to alternative education
data3<-data.frame(table(data2$CHD6t18ALTEDU))
Access<-data3[1,2] + data3[2,2]
# We are summing 1 + 2
TotCh<-sum(data3[,2])+1
#As we later show in next block, we need to add +1 in total
#because of the presence of 1 missing value
NAlt <-Access/TotCh
NAlt
## [1] 0.3106796
# This is percent of households with 6 to 18 year old children with access to alternative education
Chdrop<-sum(data$CHD6t18DS,na.rm = TRUE)
# As the column is the count, just get the total
Chdrop
## [1] 85
# this is drop-out children count
# But we don't have total age 6 to 18 children count
#we know only # households with age 6 to 18
#so we cannot take Chdrop(total drop-out children)
#we need to count how many households have at least one drop-out child
Droptb<-data.frame(table(data$CHD6t18DS))
Droptb
## Var1 Freq
## 1 0 48
## 2 1 32
## 3 2 18
## 4 3 3
## 5 4 2
# this shows househods with Age 6-18 child/children with drop-out
Drophh <-sum(Droptb[c(2:5),2])
rc<-data.frame(dim(data2))
rc
## dim.data2.
## 1 103
## 2 150
# first row is total 6 to 18 year old. We can notice 103 instead of 102 of previous table that means one missing value is not displayed in the table previously.
#also consistent with the drop-out table
pcChDrop <-Drophh/rc[1,1]
pcChDrop
## [1] 0.5339806
# This is percent of households with drop-out children