Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 16120

Different class intervalls (breaks) according to specific values in the histogram

$
0
0

I would like to create class intervals in the histogram according to the Body mass index (BMI) classification, and color the columns.The categories are:

Underweight (Severe thinness) < 16.0 -> color: red

Underweight (Moderate thinness) 16.0 – 16.9 -> color: orange

Underweight (Mild thinness) 17.0 – 18.4 -> color: pink

Normal range 18.5 – 24.9 -> color: green

Overweight (Pre-obese) 25.0 – 29.9 -> color: blue

Obese (Class I) 30.0 – 34.9 -> color: pink

Obese (Class II) 35.0 – 39.9 -> color: orange

Obese (Class III) ≥ 40.0 -> color: red

I tried the code below, but it returned the density (y-axis) and the x-axis does not contain the class ranges properly. How to plot the frequency in y-axis and the class intervals limits in histogram?

Height <- c(1.72, 1.86, 2.1, 1.7, 1.6, 1.67, 1.59, 1.88, 1.7, 1.72, 1.9, 1.88,            1.59, 1.55, 1.91, 1.61, 1.82, 1.66, 1.77, 1.74)Weight  <- c(77, 79, 102, 70, 63, 62, 55, 89, 88, 88, 128, 100, 55, 60, 79, 59,             57, 70, 72, 74)BMI <- Weight/Height^2class_range <- c(16, 16.9, 18.4, 24.9, 29.9, 34.9, 39.9)hist(BMI, freq=TRUE, main="", breaks=class_range,      col=c("red",  "orange", "pink", "green", "blue", "pink", "orange", "red"))

enter image description here


Viewing all articles
Browse latest Browse all 16120

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>