本文介绍了晶格图在函数内部不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个R代码,可以很好地工作,并且如果我在R控制台中或以RScript的形式运行它,就会获得带有绘图的位图
I have this R code, which works perfectly and i get the bitmap with the plot if i run it in R console or as a RScript
library(DBI);
library(RMySQL);
library(brew);
library(lattice);
con <- dbConnect(MySQL(),server credentials)
x <- dbGetQuery(con,"SELECT name, distance FROM distances")
bitmap("/tmp/dist_6078.bmp")
dotplot(x$distance~x$name, col='red', xlab='name', ylab='distance', main='Distance plot')
dev.off()
问题是,如果我将<%和%>之间的所有内容括起来并使用brew库,我将得到空白图像.如果我使用基本的R图,一切都可以正常工作,只有当我使用晶格时,问题才会出现.
Issue is, i am getting a blank image if i enclose everything between <% and %> and use brew library. Everything works fine if i use basic R plots, issue is only when i use lattice.
推荐答案
来自R FAQ 7.22
From the R FAQ 7.22
工作代码
library(DBI);
library(RMySQL);
library(brew);
library(lattice);
con <- dbConnect(MySQL(),server credentials)
x <- dbGetQuery(con,"SELECT name, distance FROM distances")
bitmap("/tmp/dist_6078.bmp")
plot_obj <- dotplot(x$distance~x$name, col='red', xlab='name', ylab='distance', main='Distance plot')
print(plot_obj)
dev.off()
这篇关于晶格图在函数内部不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!