From the help file on `hist()`

```
breaks one of:
a vector giving the breakpoints between histogram cells,
a function to compute the vector of breakpoints,
a single number giving the number of cells for the histogram,
a character string naming an algorithm to compute the number of cells (see ‘Details’),
a function to compute the number of cells.
In the last three cases the number is a suggestion only; as the
breakpoints will be set to pretty values, the number is limited to
1e6 (with a warning if it was larger). If breaks is a function, the
x vector is supplied to it as the only argument (and the number
of breaks is only limited by the amount of available memory).
```

So, the `breaks`

argument is only a suggestion. If you require a precise number of breaks, you must pass in an exact vector of break point values of length `number of breaks you want + 1`

.

```
set.seed(123)
x <- rnorm(1000)
n <- 5
h1 <- hist(x, breaks = n)
```

```
length(h1$counts)
#> [1] 7
```

```
my_breaks <- seq(min(x), max(x), length.out = n + 1)
h2 <- hist(x, breaks = my_breaks)
```

```
length(h2$counts)
#> [1] 5
```

^{Created on 2020-09-05 by the reprex package (v0.3.0)}