随着grid.arrange我可以安排多个ggplot在网格中人物使用类似,实现了多屏图:
library(ggplot2)
library(grid)
library(gridExtra)
Run Code Online (Sandbox Code Playgroud)
然后生成一些ggplot2图
plot5 <- grid.arrange(plot4, plot1, heights=c(3/4, 1/4), ncol=1, nrow=2)
Run Code Online (Sandbox Code Playgroud)
如何获得"不平衡"2 col布局,其中第一个col中有一个绘图,第二个col中有三个绘图?我玩弄了一个'网格网格'方法,试图用grid.arrange一个网格(例如plot5,上面)绘制另一个图,但得到了:
在ArrangeGrob中出错(...,as.table = as.table,clip = clip,main = main,:输入必须是grobs!
更新:
感谢您的建议.我会考虑viewports和grid.与此同时,感谢@DWin,layOut'wq'包中的函数非常适合我Sweave文档中的编译图:

更新2:
该arrangeGrob命令(由@baptiste建议)也运行良好,看起来非常直观 - 至少很容易改变两列的宽度.它还具有不需要`wq'包的好处.
这是我的Sweave文件中的代码:
<<label=fig5plot, echo=F, results=hide>>=
plot5<-grid.arrange(plot4, arrangeGrob(plot1, plot2, plot3, ncol=1),
ncol=2, widths=c(1,1.2))
@
\begin{figure}[]
\begin{center}
<<label=fig5,fig=TRUE,echo=T, width=10,height=12>>=
<<fig5plot>>
@
\end{center}
\caption{Combined plots using the `arrangeGrob' command.}
\label{fig:five}
\end{figure}
Run Code Online (Sandbox Code Playgroud)
产生以下输出:

顺便说一下,有人告诉我为什么出现'> NA'?
我已经开始尝试使用StatET和Texlipse来生成SWEAVE报告.在Eclipse的StatET插件(OS X 10.6.4)中启动R控制台时,我收到消息:
[INFO] The R package 'rj' is not available, R-StatET tools cannot be initialized.
Run Code Online (Sandbox Code Playgroud)
有关http://www.walware.de/goto/statet的信息指出:
"该软件包仅适用于StatET中的默认R控制台(RJ).因此,您必须使用命令行安装和更新它:"
R CMD INSTALL --no-test-load rj_*.tar.gz
Run Code Online (Sandbox Code Playgroud)
这究竟是什么意思?
在Eclipse下的"安装新软件"和网站下
WalWare - http://download.walware.de/eclipse-3.6
Run Code Online (Sandbox Code Playgroud)
它说明了这一点
RJ Core Library 0.5.0.b201008271600sw
Run Code Online (Sandbox Code Playgroud)
已安装.
任何有用的指导感激不尽.
在ggplot中boxplot,很容易使用抖动来添加具有不同程度抖动的原始数据点.零抖动以下代码
dat <- data.frame(group=c('a', 'b', 'c'), values = runif(90))
ggplot(dat, aes(group, values)) +
geom_boxplot(outlier.size = 0) +
geom_jitter(position=position_jitter(width=0), aes(colour=group), alpha=0.7) +
ylim(0, 1) + stat_summary(fun.y=mean, shape=3, col='red', geom='point') +
opts(legend.position = "right") + ylab("values") + xlab("group")
Run Code Online (Sandbox Code Playgroud)
生成下面的图.
是否可以使用零抖动但添加一个偏移量,使得这些点在一条线上但向左移动了25%的盒子宽度?我试图geom_point用dodge但这产生的抖动.
对于看似简单的问题道歉,但我似乎无法找到解决以下重新安排问题的方法.
我习惯用来read.csv读取带有标题行的文件,但我有一个带有两个'标题'行的excel电子表格 - 单元格标识符(a,b,c ... g)和三组测量值(x,y)每个单元格的z和z;每个1000s):
a b
x y z x y z
10 1 5 22 1 6
12 2 6 21 3 5
12 2 7 11 3 7
13 1 4 33 2 8
12 2 5 44 1 9
Run Code Online (Sandbox Code Playgroud)
csv文件如下:
a,,,b,,
x,y,z,x,y,z
10,1,5,22,1,6
12,2,6,21,3,5
12,2,7,11,3,7
13,1,4,33,2,8
12,2,5,44,1,9
Run Code Online (Sandbox Code Playgroud)
如何进入R中的data.frame,如下所示?
cell x y z
a 10 1 5
a 12 2 6
a 12 2 7
a 13 1 4
a 12 2 5
b …Run Code Online (Sandbox Code Playgroud) 不幸的是,我会团团团团转,当涉及到使用Sweave在Eclipse中使用StatET下OS X.
如果我Foo在默认位置创建项目/Users/xxxx/Documents/workspace/Foo,并添加Sweave文件(Foo.Rnw),当我尝试使用配置了工作目录的R控制台进行Sweave时${workspace_loc}.我收到消息:
An error occurred while running 'Processing 'Foo.Rnw'' in Workspace [R Console] R2.12_64 / RJ (Feb 26, 2011 5:58:04 PM).
Path must include project and resource name: /Foo.tex
如果我尝试Sweave相同的Foo.Rnw文件(保存在同一个项目和相同的工作区),但这次使用配置为使用外部工作目录的R控制台(例如,不使用${workspace_loc}但使用/Users/xxxx/Documents/R_data,例如),则处理该文件并生成pdf.除了所有的输出Foo.aux,Foo.log,Foo.pdf,Foo.tex,Foo-fig1.eps,Foo-fig1.pdf等)出现在外部目录/Users/xxxx/Documents/R_data,这将导致文件的混乱在一个目录.
任何有关正确安排这种方法以及保持Sweave在Eclipse中工作的建议(我非常明智地喜欢)都会受到欢迎.