在对齐网格图形对象时遇到一些麻烦 - 已经阅读了我能找到的所有文档,包括Murrell书籍,但没有成功.我认为我想做的事情非常简单,所以希望我很简单.
这是一个可重现的例子,它将在Hadley的hflights
包中按目的地制作所有航空承运人的PDF (反映我在不同的数据集上尝试做的事情).
require(hflights)
require(gridExtra)
require(Cairo)
make_table <- function(df) {
p <- tableGrob(
df
,padding.h=unit(.25, "mm")
,show.rownames=FALSE
,gpar.coretext = gpar(fontsize=8, lineheight=0)
#this doesn't seem to justify the table
,just = c("bottom")
,show.box = T
)
return(p)
}
dests <- unique(hflights$Dest)
#list to hold the plots
plot_list <- list()
#loop over destinations and make a simple report
for (i in dests) {
#just this destination
this_dest <- hflights[hflights$Dest == i, ]
#the title
title <- textGrob(label = …
Run Code Online (Sandbox Code Playgroud) 我想将一些数据插入到与下一年的日期相关联的表中.我实际上只需要插入工作日.
BEGIN
FOR i IN 1..365 LOOP
INSERT INTO MY_TABLE (ID, MY_DATE)
VALUES (i, (to_date(sysdate,'DD-MON-YY')-1)+i);
END LOOP;
END;
Run Code Online (Sandbox Code Playgroud)
我可以通过返回并删除周末的行来解决我的问题,但这似乎相当不优雅 - 有人能想到一种方法来修改我的循环以便它跳过周末吗?
这实际上是两个问题之一 - 或者:
1)如何在不向当前图形输出发送任何内容的情况下存储print()调用[ie x <- print(something)
]的结果?-要么-
2)ggplot中是否有一个函数或方法将一个plot()调用存储到一个变量而不plot()
直接调用?ggplotGrob
是在球场,但是ggplotGrob
对象不会返回列表$data
中的列表,就像将结果存储print()
到变量时一样.
我正在使用从这个 SO答案中提取的技术来提取geom_density曲线的点,然后使用该数据生成一些注释.我已经概述了下面的问题 - 当我将其称为函数时,我在pdf中得到了不需要的中间绘图对象,以及最终的绘图.目标是摆脱那个不受欢迎的阴谋; 鉴于基地hist()
有一个plot = FALSE
选项,我希望知道更多关于R视口的人能够修复我的plot()
呼叫(解决方案#1),但任何解决方案都很好,坦率地说.
library(ggplot2)
library(plyr)
demo <- function (df) {
p <- ggplot(
df
,aes(
x = rating
)
) +
geom_density()
#plot the object so we can access $data
render_plot <- plot(p + ggtitle("Don't want this plot"))
#grab just the DF for the density …
Run Code Online (Sandbox Code Playgroud) 上下文:尝试有效地解决我的无可见性绑定 CMD检查问题.
我尝试了两种口味captureOutput
:
cmd_output <- R.utils::captureOutput(devtools::check(args="--no-tests"))
cmd_output <- utils::capture.output(devtools::check())
Run Code Online (Sandbox Code Playgroud)
和下沉
sink("cmd_output.txt")
devtools::check(args="--no-tests")
sink()
unlink("cmd_output.txt")
Run Code Online (Sandbox Code Playgroud)
无济于事.devtools::document()
当我想要CMD注意和警告时,我最终得到了输出.