0

With base R (ie. no libraries):

boxplot(apartamentos$Preco ~ apartamentos$Tipologia, main = "Intervalo de preços por tipologia", options(scipen = 5))

Returns:

enter image description here

I want to add a thousands separator to the y-axis.

I know this should be simple and I've searched the documentation, but it's really complicated and I can't find it anywhere, so thanks for helping.

d.b
  • 32,245
  • 6
  • 36
  • 77

1 Answers1

2
set.seed(42)
d = abs(rnorm(1000)) * 10000
graphics.off()
boxplot(d, yaxt = "n")
axis(2, pretty(d), formatC(pretty(d), format = "f", big.mark = ",", digits = 0))
d.b
  • 32,245
  • 6
  • 36
  • 77
  • Hi, thanks! That's really scary. It kind of removes the original y-axis and adds a new one with the thousands separator, but ends on 800.000 instead of 1.000.000. –  Dec 03 '19 at 17:35
  • @NunoNogueira, that's because of the `pretty`. You can instead give your own breaks manually at desired intervals. Read more at `?axis` – d.b Dec 03 '19 at 17:39