그래서, 재현성 데이터 :
set.seed(1)
phuong <- data.frame(Eeff = rnorm(100,31))
phuong$Neff <- rnorm(100,19.7 + .36*phuong$Eeff)
# Create the lm object ahead of time
lm1 <- lm(Neff ~ Eeff, data = phuong)
# Create the character string that you want to print
tp <- sprintf("%s=%.1f + %.2f %s", all.vars(formula(lm1))[1],
coef(lm1)[1], coef(lm1)[2], all.vars(formula(lm1))[2])
# Change the mypanel function to use the lm1 object
mypanel<-function(x,y,...){
panel.xyplot(x, y, ...)
panel.abline(lm1)
panel.text(30,33,labels=tp)
}
library(lattice)
# and off we go.
xyplot(Neff~Eeff,data=phuong,panel=mypanel,
col="black",
pch=18,xlab="Energy efficiency (%)",
ylab = "Nitrogen efficiency (%)", main="(a)")
참조'panel.text', 당신이 당신의'mypanel' 기능에 추가 할 수있는 기능?. – BenBarnes
그것은 나를 위해 작동하지 않습니다. 이것은 mypanel 코드입니다 : mypanel <-function (x, y, ...) { + panel.xyplot (...) + panel.abline (lm (Neff ~ Eeff, data = phuong)) + 패널 . 텍스트 (30,30, 레이블 = tp) +} 제게 도와 주시겠습니까? –
도움을 받기 쉽도록 [재현 가능한 예] (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)를 게시하십시오. – BenBarnes