ggplot histogram as a percent of a specific group

Viewed 218

I'm new to R, and have created some simple histograms of a categorical independent variable vs the dependent variable. All facet wrapped according to the categories.

In this case I am using sensitive data, so cannot share any data.

Code

ggplot(merged, aes(CV)) +
  geom_histogram(binwidth = 0.5) +
  facet_wrap(~BUILDING_AGE, ncol = 2) +
  labs(title = "BUILDING_AGE vs CV", y = "Co-efficient of variation", x = "BUILDING_AGE")

Where CV = coefficient of variation (continuous dependent variable) and BUILDING_AGE is the age of the buildings (categorical independent variable - with 7 categories/groups 1-7)

The problem

The problem is that some of the categories have only a small amount of data relative to the other categories, so when I plot the histogram I cannot see the histogram and distribution of the data in these groups with smaller amounts of data.

Ie: the y-axis (counts) is scaled far too large for the categories with very low counts.

Question

Is there a way that each of the facet wrapped windows y-axis could be rescaled according to each of the categories they are displaying?

Hope this makes sense.

Thank you.

1 Answers
Related