本文介绍了在Knitr中找不到功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编译以下文档时,我有一个奇怪的问题. se.ranef(model)se.fixef(model)R中工作正常.但是,如下图所示,突然找不到它们.请问出了什么问题?有人可以帮我吗?谢谢!

I had an odd question when compiling the following document. se.ranef(model) and se.fixef(model) worked fine in R. However, as the following picture shows, suddenly, they could not be found. What went wrong, please? Could anyone help me, please? Thank you!

\documentclass[english]{exam}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{bigints}
\usepackage[stable]{footmisc}
\usepackage{ulem}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{booktabs}
\usepackage{pdfpages}

\printanswers
\unframedsolutions

\begin{document}

\begin{questions}

\question 

\begin{solution}

<<>>=
library(lme4)
X <- 1:24
coag <- c(62, 60, 63, 59, 63, 67, 71, 64, 65, 66, 68, 66, 
          71, 67, 68, 68, 56, 62, 60, 61, 63, 64, 63, 59)
diet <- c("A", "A", "A",  "A",  "B",  "B",  "B",  "B",  "B",  "B", "C", 
          "C", "C", "C", "C", "C", "D", "D", "D", "D",  "D", "D", "D", "D")
#coag <- data.frame(cbind(X, coag, diet))
#coag <- read.table("coag.csv", sep=",", header=TRUE)
model <- lmer(coag~(1|diet))
@

<<>>=
se.ranef(model)
@

<<>>=
se.fixef(model)
@

\end{solution}

\end{questions}

\end{document}

推荐答案

se.fixefse.ranef是不是来自base或nlme的函数. knitr在运行新环境时会启动它,因此不会加载任何其他软件包.

se.fixef and se.ranef are functions not from base, or nlme. knitr starts a new environment when you run it, so any other packages are not loaded.

尝试加载从一开始就获得它们的库,然后将其添加到加载nlme的位置:

Try loading the library you got them from first, add this to where you load nlme:

library(arm)

这篇关于在Knitr中找不到功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 05:01