使用ggplot,未加载在r控制台中的图

发布于 2025-02-12 16:05:45 字数 1073 浏览 0 评论 0原文

每当我运行项目中包含图的代码块时,它都不会加载但没有显示任何错误消息,就好像控制台被冻结了,然后最终会淘汰。我已经运行了20次或更多的代码脚本,一切都很好,但是现在由于某种原因未知,它就无法正常工作。

我已经尝试过:

  • 重新启动R
  • 重新安装R
  • 更新和安装软件包再次
  • 运行以前运行的不同RMD/项目,(它们也不起作用)

任何其他代码块都会执行罚款,而其他软件包似乎都像往常一样运行。我目前正在运行最新的rstudio 4.1.3 build 492。

无论如何,这是我的代码:

budget_revenue <- ggplot(data = filtered_movies2) + 
  geom_point(mapping = aes(x = budget, y = revenue, colour = genre_1)) + 
  facet_wrap(~ genre_1, nrow = 2) +
  labs(title = "Budget and Revenue by Genre", x = "Movie Budget", y = "Gross Revenue") +
  scale_y_continuous("Gross Revenue", 
                       breaks = scales::breaks_extended(8),
                       labels = scales::label_dollar()) + 
  scale_x_continuous("Movie Budget",
                     breaks = scales::breaks_extended(5),
                     labels = scales::label_dollar()) +
  theme_minimal() +
   theme(axis.text.x = element_text(angle = 45, vjust = 0.5)) +
  theme(legend.position = "none")
  
  
  budget_revenue +
    scale_colour_viridis_d() 

Whenever I run code chunks containing plots within my project, it fails to load but doesn't display any error message, as if the console is frozen and then eventually times out. I have ran this code script 20 times or more and it all worked fine, but now for some reason unknown it just won't work.

I have tried:

  • Restarting R
  • Reinstalling R
  • Updating and installing packages again
  • Running different Rmd's/projects which have been run before, (they don't work either)

Any other code chunk will execute fine and other packages all seem to be operating as usual. I am currently running the latest Rstudio 4.1.3 build 492.

Here is my code anyway:

budget_revenue <- ggplot(data = filtered_movies2) + 
  geom_point(mapping = aes(x = budget, y = revenue, colour = genre_1)) + 
  facet_wrap(~ genre_1, nrow = 2) +
  labs(title = "Budget and Revenue by Genre", x = "Movie Budget", y = "Gross Revenue") +
  scale_y_continuous("Gross Revenue", 
                       breaks = scales::breaks_extended(8),
                       labels = scales::label_dollar()) + 
  scale_x_continuous("Movie Budget",
                     breaks = scales::breaks_extended(5),
                     labels = scales::label_dollar()) +
  theme_minimal() +
   theme(axis.text.x = element_text(angle = 45, vjust = 0.5)) +
  theme(legend.position = "none")
  
  
  budget_revenue +
    scale_colour_viridis_d() 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

胡渣熟男 2025-02-19 16:05:45

下关闭并重新启动我的机器,它允许所有更新和恢复原状的生效,并解决了问题。

With closing down and rebooting my machine, it allowed for all updates and reinstallation's to take effect and the issue was solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文