我在这里缺少什么?没有得到合适的传奇标签.
p <- ggplot(mtcars, aes(factor(cyl), mpg))+ geom_boxplot(aes(fill = cyl))
p <- p + labs(fill=expression(paste("Temperature\n (", degree ~ F, " )")))
p
Run Code Online (Sandbox Code Playgroud)
我使用这段代码来制作数字 Sweave
<<label=fig1plot, include=FALSE >>=
plot(cars)
@
\begin{figure}
\begin{center}
<<label=fig1, fig=TRUE, echo=FALSE>>=
<<fig1plot>>
@
\end{center}
\caption{Some caption}
\label{fig:fig1plot}
\end{figure}
<<label=fig2plot, include=FALSE >>=
plot(table(rpois(100,5)), type = "h", col = "red", lwd=10, main="rpois(100,lambda=5)")
@
\begin{figure}
\begin{center}
<<label=fig2, fig=TRUE, echo=FALSE>>=
<<fig2plot>>
@
\end{center}
\caption{Some caption}
\label{fig:fig2plot}
\end{figure}
Run Code Online (Sandbox Code Playgroud)
现在我想把这两个数字并排放在一起,并有如图1(a)和图1(b)所示的标题.任何想法,评论和指南都非常感谢.在此先感谢您的时间和帮助.
我安装asreml.d
上R 2.14.0
使用安装从本地zip文件包 从包菜单.当我尝试加载包时library(asreml.d)
,我收到以下错误
Error in library(asreml.d) :
package ‘asreml.d’ does not have a NAMESPACE and should be re-installed
Run Code Online (Sandbox Code Playgroud)
重新安装后仍会出现错误.任何评论,想法和解决方案来解决这个问题将受到高度赞赏.在此先感谢您的时间和帮助.
aov
可以通过以下model.tables
函数获得最小二乘平均值及其对象的标准误差:
npk.aov <- aov(yield ~ block + N*P*K, npk)
model.tables(npk.aov, "means", se = TRUE)
Run Code Online (Sandbox Code Playgroud)
我想知道如何得到广义最小二乘意味着它们的标准误差nlme
或lme4
对象:
library(nlme)
data(Machines)
fm1Machine <- lme(score ~ Machine, data = Machines, random = ~ 1 | Worker )
Run Code Online (Sandbox Code Playgroud)
任何评论和提示将受到高度赞赏.谢谢
以下命令
library(ggplot2)
ggplot(PlantGrowth, aes(x=group, y=weight)) + geom_boxplot()
Run Code Online (Sandbox Code Playgroud)
生成此图表.
.我想知道如何将xlabels作为ctrl,trt_1和trt_2,这里的1和2都在下标中.因为我需要以png格式绘制图形所以我避免使用tikzDevice和pgfSweave.在此先感谢您的帮助.
aggregate
功能正常
aggregate(weight ~ feed, data = chickwts, mean)
feed weight
1 casein 323.5833
2 horsebean 160.2000
3 linseed 218.7500
4 meatmeal 276.9091
5 soybean 246.4286
6 sunflower 328.9167
Run Code Online (Sandbox Code Playgroud)
但library(memisc)
在R 2.14.1中加载后,相同的代码会产生以下错误
Error in `[.default`(xj, i) : invalid subscript type 'closure'
Run Code Online (Sandbox Code Playgroud)
有什么问题以及如何解决这个问题?在此先感谢您的帮助.
我试图绘制这个基础情节
df <-
structure(list(X = c(1e-04, 2e-04, 3e-04, 4e-04, 5e-04, 6e-04,
7e-04, 8e-04, 9e-04, 0.001, 0.0011, 0.0012, 0.0013, 0.0014, 0.0015,
0.0016, 0.0017, 0.0018, 0.0019, 0.002, 0.0021, 0.0022, 0.0023,
0.0024, 0.0025, 0.0026, 0.0027, 0.0028, 0.0029, 0.003, 0.0031,
0.0032, 0.0033, 0.0034, 0.0035, 0.0036, 0.0037, 0.0038, 0.0039,
0.004, 0.0041, 0.0042, 0.0043, 0.0044, 0.0045, 0.0046, 0.0047,
0.0048, 0.0049, 0.005, 0.0051, 0.0052, 0.0053, 0.0054, 0.0055,
0.0056, 0.0057, 0.0058, 0.0059, 0.006, 0.0061, 0.0062, 0.0063,
0.0064, 0.0065, 0.0066, 0.0067, 0.0068, 0.0069, 0.007, 0.0071,
0.0072, 0.0073, 0.0074, 0.0075, …
Run Code Online (Sandbox Code Playgroud) 使用以下ggplot2
代码,我可以将绘图的大小设置为屏幕上的两倍.
ratings <- qplot(rating, data=movies, geom="histogram")
ggsave(ratings, file="ratings.pdf", scale=2)
Run Code Online (Sandbox Code Playgroud)
我想知道如何在屏幕上显示两倍大的情节knitr
.
<< label = test, fig.width = 6, fig.height = 6, out.width = '.6\\linewidth'>>=
ratings <- qplot(rating, data=movies, geom="histogram")
@
Run Code Online (Sandbox Code Playgroud)
但没有得到两倍于屏幕的情节.我非常感谢你的帮助.谢谢
由于版本1.2 knitr
有一个新功能pandoc
,可以直接通过pandoc将markdown文档转换为其他格式R
(参见此处).例如
library(knitr)
pandoc('foo.md', format='html') # HTML
Run Code Online (Sandbox Code Playgroud)
我想知道如何将Markdown文档(请参阅针对MWE的knitr-slides.md)转换为HTML5
幻灯片.谢谢
lm
功能参数可以通过以下方式获得:
args(lm)
Run Code Online (Sandbox Code Playgroud)
产量
function (formula, data, subset, weights, na.action, method = "qr",
model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE,
contrasts = NULL, offset, ...)
NULL
Run Code Online (Sandbox Code Playgroud)
问题
如何获得:
lm (formula, data, subset, weights, na.action, method = "qr",
model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE,
contrasts = NULL, offset, ...)
Run Code Online (Sandbox Code Playgroud)
与每个参数的描述(不完整的帮助)Sweave
或用于knitr
.谢谢
编辑
使用@Ananda提供的funExtract功能,我非常接近我想要的结果.这是我的Rnw
文件的代码与输出.
\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Arguments for lm …
Run Code Online (Sandbox Code Playgroud)