Big issue with ggplot2 (R) and coord_cartesian

Hello,
Since installing feasts package, I can't draw plots with coord_cartesian

moyennesMois2 <- notes2223 %>%
  mutate(Annee = ifelse(Annee == 2022, "2022", "2023")) %>%
  group_by(Annee, Mois) %>% 
  dplyr::summarize(moyenne = mean(Note, na.rm = TRUE))

# Tracer le graphique
ggplot(moyennesMois2, aes(x = Mois, y = moyenne, fill = factor(Annee))) + 
  geom_bar(stat = "identity", position = "dodge") +
  geom_text(aes(label = round(moyenne, 1)), position = position_dodge(width = 0.9), vjust = -0.5, size = 2.5) +
  scale_x_discrete(labels = month.abb) +
    coord_cartesian(ylim=c(6,9.25))+
  scale_color_manual(values= c("2022" = "grey75", "2023" = "cyan3"))+
   scale_fill_manual(values= c("2022" = "grey75", "2023" = "cyan3"), name="Année")+
  labs(title = "Moyenne des notes par mois",
       subtitle = "2022 vs. 2023", x = "Mois", y = "Moyenne globale") +
  theme_clean(base_size = 5)
Erreur dans obj_is_vector(limits) : 
  impossible de trouver la fonction "obj_is_vector"
2.
check_coord_limits(ylim)
1.
coord_cartesian(ylim = c(6, 9.25))

I have tried to un install and reinstall ggplot2, vctrs and remove feasts but still doesn't work !

Could you supply us with some sample data?
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here between
```

```

Te problem is not related to the data because before installing feasts my plot worked perfectly. Now, I have uninstall feasts but a basic example like this doesn't work

> library(ggplot2)
Message d'avis :
le package ‘ggplot2’ a été compilé avec la version R 4.2.3 
> ggplot(mtcars, aes(wt, mpg)) + geom_point() + coord_cartesian(ylim = c(18, 20))
Erreur dans obj_is_vector(limits) : 
  impossible de trouver la fonction "obj_is_vector"

It may be that you are missising the {vctrs} package. It is a ggplot2 dependency. Try

 install.packages("vctrs") 

and see if that helps.

Just to make sure the error persists with a reproducible example, could you confirm that the same error occurs with this?

library(tidyverse)

tibble(m = month.abb |> rep(2), y = rep(c('1','2'), each = 12), n = 1:24) |> 
  ggplot(aes(m, n, fill = y)) +
  geom_col() +
  coord_cartesian(ylim = c(6, 25))

Created on 2024-03-27 with reprex v2.0.2

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.