【发布时间】:2021-10-23 16:52:12
【问题描述】:
我正在尝试在lattice 图中自动添加多个模型评估参数。我正在使用以下代码
library(lattice)
library(tidyverse)
library(hydroGOF)
#Calculation of model evaluation parameters
summ <- iris %>%
group_by(Species) %>%
summarise(Rsq = cor(Sepal.Length, Petal.Length)^2,
RMSE = RMSE(Sepal.Length, Petal.Length),
NSE = NSE(Sepal.Length, Petal.Length)) %>%
mutate_if(is.numeric, round, digits=2)
#Make multipanel plot
xyplot(Petal.Length ~ Sepal.Length | Species, data = iris, pch = 23,
layout=c(3,1), type = c("p", "r"),
scales=list(cex=c(1.4,1.4), alternating=1, relation = "free"),
xlab = list(label="Sepal Length", fontsize=20),
ylab = list(label="Petal Length", fontsize=20))
编辑
虽然将马赛克 package 中的 panel.lmbands 添加到解决方案 (1) 和 (3) 中,但我无法使用解决方案 (2) 实现它。这是代码
library(mosaic)
p2 <- xyplot(Petal.Length ~ Sepal.Length | Species, data = iris, pch = 23,
layout=c(3,1),
band.lty = c(conf =2, pred = 1),
band.lwd =c(conf =1, pred = 1),
npts = 500,
panel = panel.lmbands,
scales=list(cex=c(1.4,1.4), alternating=1, relation = "free"),
xlab = list(label="Sepal Length", fontsize=20),
ylab = list(label="Petal Length", fontsize=20),
panel = function(x, ...) {
i <- panel.number()
panel.xyplot(x, ...)
panel.key(as.expression(summ$ann[[i]]), points = FALSE)
})
p2
它返回我以下错误
xyplot.formula 中的错误(Petal.Length ~ Sepal.Length | Species, data = iris, : 由多个实际参数匹配的形式参数“面板”
预期的输出将如下所示
【问题讨论】: