The height of each bar represents the percentage of the total patients in that category. ![]() Along the horizontal axis ( x-axis) are the different BMI categories whilst on the vertical axis (y-axis) is the percentage (%). Figure 2.2 shows the BMI categories for 428 patients. When shown graphically this is called a bar plot.Ī simple bar plot is an easy way to make comparisons across categories. For categorical variables, such as sex and bmi_cat, it is straightforward to present the number in each category, usually indicating the frequency and percentage of the total number of patients. While frequency tables are extremely useful, the best way to investigate a dataset is to plot it. In contrast, the percentage of obese male patients (9.9%) is lower than obese female patients (16.5%). We can see that the percentage of overweight male patients (47.6%) is higher than overweight female patients (32.1%). We can generate a frequency table for the sex variable using the freq() function from the package: Additionally, we can express the frequencies as proportions of the total sample size (relative frequencies, %). The set of frequencies of all the possible categories is called the frequency distribution of the variable. The first step to analyze categorical data is to count the different types of labels and calculate the frequencies. Now, both variables, sex and bmi_cat, have become factors with levels.Ģ.3 Summarizing Categorical Data (Frequency Statistics) $ bmi_cat normal, normal, obese, obese, normal, normal, normal, normal, … $ sex male, female, male, male, male, female, female, male, female, … We can use the factor() function inside the mutate() to convert the variables to factors as follows: We might have noticed that the categorical variables sex and bmi_cat are recognized of character type. ![]() bmi_cat (4 levels: underweight, normal, overweight, obese). ![]() The data set arrhythmia has 428 patients (rows) and includes 8 variables (columns) as follows: Median :48.00 Mode :character Median :165 Median : 70.0
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |