【发布时间】:2016-05-24 15:34:23
【问题描述】:
我正在使用 rApache 来显示在 R 中创建的封装图。现在我只需要面对一个问题。 如果文档中只有嵌套 R 代码,我认为 HTML 文件会呈现为某种单一的 png 图像。
但是,我希望将其呈现为包含图形的文档。因此,当我在<% ... %> 标签之前或之内添加 HTML 内容时,我会得到一个损坏的图像标志作为输出。
我怎样才能做到,我可以在 HTML 文档中使用 plot 命令?
<h1> Plot Content </h1> // adding this causes a broken image
<%
setContentType("image/png")
t <- tempfile()
png(t,type="cairo")
rndDistribution <- rnorm(100)
plot(rndDistribution)
dev.off()
sendBin(readBin(t,'raw',n=file.info(t)$size))
unlink(t)
%>
我的 apache.conf:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html/R>
SetHandler r-script
RHandler brew::brew
</Directory>
【问题讨论】: