gpt4 book ai didi

r - grDevices::png中的错误

转载 作者:行者123 更新时间:2023-12-04 09:55:41 26 4
gpt4 key购买 nike

quick.hist<-ggplot(ufo.us, aes(X=DateOccured))+geom_histogram()+scale_x_date()
ggsave(plot=quick.hist,filename= "../images/hist.png",height=6, width=8)

文件格式很简单:

它包含2个日期,城市,州,时长

我在绘图期间出错:即在 ggsave()期间
Error in grDevices::png(..., width = width, height = height, res = dpi,  
unable to start png() device

另外:警告消息:
 In grDevices::png(..., width = width, height = height, res = dpi,  
unable to open file '../images/hist.png' for writing

In grDevices::png(..., width = width, height = height, res = dpi,
opening device failed

我对R很陌生,并且遇到了错误。我刚刚开始复制用于直方图的书籍代码,这是从书籍机器学习黑客的角度出发的第一章。

最佳答案

我最近有同样的问题。从源代码编译R而未安装适当的库时,就会发生这种情况。因此,R根本不知道如何与png设备对话。

为了解决此问题,只需安装以下软件包(例如,使用Ubuntu16.04)

sudo apt install libcairo2-dev libjpeg9-dev

并再次运行./configure。

如果这些库已足够,则应在配置末尾将 PNG cairo 都列为“其他功能”。所以如果他们都没有出现使用
cat config.log | grep skipped

你已准备好出发。

关于r - grDevices::png中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23387992/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com