Setup

make composite ppt column: the lowest value (right or left) becomes ppt_knee value. if both left and right are NA, stays NA; if one (left or right) is NA, uses the other value. make bmi column.

oahelp_urbmed$ppt_knee <- pmin(oahelp_urbmed$ppt_knee_left, oahelp_urbmed$ppt_knee_right, na.rm = TRUE)
oahelp_urbmed$bmi <- oahelp_urbmed$weight.x / (oahelp_urbmed$height_standing.x/100)^2

Urbanicity score distribution

summary stats of all urbanicity scores

summary(oahelp_urbmed$urb_score)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.365  23.188  31.848  33.084  43.345  52.438

histogram of all urbanicity scores. bin width = 2

ggplot(oahelp_urbmed, aes(x = urb_score)) +
  geom_histogram(binwidth = 2, fill= "#678096", color="#C5A35933") +
  labs(title = "Histogram of Urbanicity Scores",
       x = "Urbanicity Score",
       y = "Frequency")+
  theme(
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank()
)

Knee PPT distribution with 2 different urbanicity score thresholds

filter

urb score <30, bmi <30, has ppt_knee value (28 people with ppt_knee value have urb score < 30 and bmi >= 30, are not included in following plot)

filtered <- oahelp_urbmed %>% 
  filter(urb_score < 30, !is.na(ppt_knee), bmi < 30)

nrow(filtered)
## [1] 192

histogram. bin width = 1

ggplot(filtered, aes(x = ppt_knee)) +
  geom_histogram(binwidth = 1, fill= "#678096", color="#C5A35933") +
  labs(title = "Histogram of Knee PPT",
       x = "Pressure pain threshold (kg/cm²)",
       y = "Frequency")+
  scale_x_continuous(breaks = seq(1, 13, by=1))+
  scale_y_continuous(breaks = seq(0, 150, by=40))+
  theme(
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank()
)

filter

urb score <31.848, bmi <30, has ppt_knee value (29 people with ppt_knee value have urb score < 30 and bmi >= 30, are not included in following plot)

filtered <- oahelp_urbmed %>% 
  filter(urb_score < 31.848, !is.na(ppt_knee), bmi < 30)

nrow(filtered)
## [1] 215

histogram. bin width = 1

ggplot(filtered, aes(x = ppt_knee)) +
  geom_histogram(binwidth = 1, fill= "#678096", color="#C5A35933") +
  labs(title = "Histogram of Knee PPT",
       x = "Pressure pain threshold (kg/cm²)",
       y = "Frequency")+
  scale_x_continuous(breaks = seq(1, 13, by=1))+
  scale_y_continuous(breaks = seq(0, 150, by=40))+
  theme(
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank()
)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.