将直方图从R导出到Excel [英] Exporting Histogram from R to Excel

查看:296
本文介绍了将直方图从R导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中有一些数据,我想表示为直方图(实际上,我将有6个直方图),然后将这些图导出到一个excel文件中。我刚刚使用了hist()函数,但我也在试验ggplot2函数。
每个直方图都有10,000个数据,所以我不能只是输出原始数据并在excel中创建直方图(我假设这将导致一个可笑的大小的excel文件,我不想要)



有没有办法导出我的图?

解决方案

p> excel.link包是RDCOMClient的包装器。



以下示例仅在正常的RGui(不是RStudio)的R 3.0.1中适用于我。 / p>

 #加载包
require(excel.link)

#plot something
plot(cos)

#将图保存到tmp文件
cos.plot = current.graphics()

#添加excel工作簿
xl。 workbook.add()

#添加工作表excel工作簿
xl.sheet.add()

#将您的图形从单元格A1的左上角开始
xl [a1] =列表(余弦绘图,cos.plot,余弦绘图结束)


I have some data in R that I would like to represent as a histogram (actually, I'll have 6 histograms) and then export those graphs into an excel file. I have just been using the hist() function, but I'm also experimenting with ggplot2 functions. Every histogram has 10,000 pieces of data, so I can't just export the raw data and create the histograms in excel (I'm assuming that this would lead to a ridiculously sized excel file, which I don't want).

Is there any way I can export my graphs?

解决方案

The excel.link package is a wrapper to RDCOMClient.

The following example only worked for me in R 3.0.1 in the normal RGui (not RStudio).

# load package
require(excel.link)

# plot something
plot(cos)

# save graph to tmp file
cos.plot=current.graphics()

# add excel workbook
xl.workbook.add()

# add sheet to excel workbook
xl.sheet.add()

# put your graph starting at the top left in cell A1
xl[a1]=list("Cosine plotting",cos.plot,"End of cosine plotting")

这篇关于将直方图从R导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆