Reputation: 51
my code is as follows:
hist(df2, main = paste("Histogram of Mutual Fund Survival Times"), xlab = "Number of Months", ylab = "Frequency of Mutual Funds", labels = TRUE, ylim=c(0,350))
My bin widths are currently 50. I would ideally like to change the first bin to a width of 36 and leave the rest at 50. Is this possible?
If not, all bin widths at 36 are fine.
Many Thanks
Upvotes: 0
Views: 1125
Reputation: 5747
You can create bins with the breaks
argument of hist
. The breaks are the lower limit of each bin. They can be whatever you want. Here is an exaggerated example. In generates some errors, but it works.
hist(runif(n = 1000, min = 1, max = 100), breaks = c(1, 2, 10, 25, 100))
Rather than manually provide the breaks, you can have R calculate them from your data:
hist(x, breaks = c(min(x), seq(min(x) + 36, max(x), 50)))
Upvotes: 1