Part 8 · How do you build your first CNA model?
Module 16 · How do you create the dataset?
Type the supervision table into R
By the end of this module you will be able to
- Build a data.frame from typed values.
- Map each column to one condition.
- Print a dataset to check it.
Let's recreate the Module 9 table as a data.frame, which is just R's name for a spreadsheet. Each c(...) is one column, listing the six facilities' values from top to bottom. Type carefully; R is a stickler for commas.
first_model.R
library(cna) # build the supportive-supervision dataset (6 facilities) # conditions are GAPS; outcome LowCov = 1 means coverage fell below target immunization <- data.frame( NoTrain = c(0, 0, 1, 0, 1, 0), NoCold = c(1, 0, 1, 0, 0, 1), NoSuper = c(0, 1, 0, 0, 0, 1), NoComm = c(0, 0, 1, 1, 0, 1), LowCov = c(1, 1, 1, 0, 0, 1) ) # look at it immunization
Output NoTrain NoCold NoSuper NoComm LowCov
1 0 1 0 0 1
2 0 0 1 0 1
3 1 1 0 1 1
4 0 0 0 1 0
5 1 0 0 0 0
6 0 1 1 1 1
1 0 1 0 0 1
2 0 0 1 0 1
3 1 1 0 1 1
4 0 0 0 1 0
5 1 0 0 0 0
6 0 1 1 1 1
Six rows, five columns. R now holds your supervision data exactly as you designed it, missing children and all.
Reflect
Recreate the table yourself.
- Did every column get the right number of values, one per facility?
- What would happen if one c(...) had a value too few?