x创建的ggplot2对象绘制到从RDS文件导入的R

x创建的ggplot2对象绘制到从RDS文件导入的R

本文介绍了无法将使用R 3.x创建的ggplot2对象绘制到从RDS文件导入的R 4.x中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将包含一些ggplot2对象的列表导出到了从R 3.6.1会话生成的.RDS文件中.然后,尝试将其导入R 4.0.0会话,并收到以下错误:

I exported a list with some ggplot2 objects into a .RDS file, generated from a R 3.6.1 session. Then, tried importing it into a R 4.0.0 session and got the following error:

Error in identicalUnits(x) :
  old version of unit class is no longer allowed

我可以读取这些图并将其导入到R对象中,但无法绘制.它们实际上具有所有数据(数据,图层,比例尺映射...),但是ggplot2并未绘制它们.

I can read and import these plots into an R object, but CAN'T plot. They actually have all the data within (data, layers, scales mapping...) but ggplot2 is not plotting them.

有什么办法解决吗?你们中有人遇到过这个问题吗? ggplot2是否计划更新库,以便我们可以导入较旧的版本图?希望您能帮助我找到解决方案,或者至少是补丁.谢谢!

Is there any way around it? Have any of you encountered with this issue? Would ggplot2have plans to update the library so we can import older version plots? Hope you can help me find a solution, or at least a patch. Thanks!

推荐答案

在全局设置自定义主题后,我遇到了同样的问题.我注意到,如果我用'complete = F'重新定义主题,然后设置新主题,则绘图将正常工作.不幸的是,没有更好的解决方案.对于新编码的ggplot对象,也就是未从.Rds文件读取的ggplot对象,也会发生这种情况.

I had the same issue which happened after I had globally set a custom theme.I noticed that if I re-defined the theme with 'complete = F' and then set the new theme the plotting works normally. Don't have a better solution yet unfortunately.This also happened with ggplot objects that were newly coded, i.e. not read from a .Rds file.

这篇关于无法将使用R 3.x创建的ggplot2对象绘制到从RDS文件导入的R 4.x中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 06:15