Why is the time axis in my ggplot2 gantt diagram German?

Viewed 65

I have the following tibble and wanted to make a Gantt diagram with it as in this tutorial, which worked fine on first glance.

gantt <- tibble(wave = c("Baseline", "Follow-up 1", "Follow-up 2"),
                start = c(min(base$submitdate), min(fup1$submitdate), min(fup2$submitdate)),
                end = c(max(base$submitdate), max(fup1$submitdate), max(fup2$submitdate)))

# A tibble: 3 x 3
  wave        start               end                
  <chr>       <dttm>              <dttm>             
1 Baseline    2020-07-09 17:21:19 2021-04-11 09:29:19
2 Follow-up 1 2020-11-24 17:14:08 2021-02-27 04:51:05
3 Follow-up 2 2021-03-01 11:42:04 2021-04-11 15:57:58

ggplot(gantt, aes(x=start, xend=end, y=wave, yend=wave)) +
  geom_segment(size = 10) 

However, as you can see in the image below, the months are printed in German. It's only a minimal difference, but it says "Okt" instead of "Oct".

Gantt diagram

I have to admit, I am German and the rest of my computer is set to German, but nothing in my RStudio is. So why does it print the month like that and how can I change it?

1 Answers

This depends of the setting of your "locale". Use e.g. the following code in your terminal to set this to "English" on Windows

Sys.setlocale("LC_ALL", "English")

Your X-axis labels will now follow the new locale setting.

FYI: SessionInfo() will also reflect the change:

...
locale:

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252   
...
Related