R: Bar chart with user gaps for user range x

I need to build a vector of numbers. Let's say these numbers range from 0 to 1000. I need to make a histogram where the x axis goes from 100 to 500, and I want to indicate the number of boxes in 10. How to do this?

I know how to use xlim and split separately, but I don’t know how to make a given number of boxes within a user range.

+4
source share
1 answer

This is actually a very good question! It bothered me all the time, but finally your question hit me, finally resolving :-)

, hist(x, xlim = c(100, 500), breaks = 9), breaks x, xlim ( , xlim , ). hist, .

, - "xlim" , hist:

x <- runif(1000, 0, 1000) # example data
hist(x[x > 100 & x < 500], breaks = 9)

breaks .

. ?hist

+3

Source: https://habr.com/ru/post/1546070/


All Articles