Now that we have categorized age, we can run a cross-tab which counts outcomes by the age category.
Since there are only two outcomes and two age categories, this results in a four-cell crosstab:
- First, display the results using the special Databricks
display
command. - After the results appear as shown in the table below, you can click the
plot
button (2nd icon on the bottom left) and the Customized Plot dialogue will appear, which will allow the results to be plotted as a bar chart. The plot show that diabetes occurs more frequently in the higher age group than in the lower age group, while the reverse is true for the non-diabetes group:
table <- crosstab(filtered, "outcome", "agecat") display(as.data.frame(table))