Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用不同数据的格中的面板函数_R_Panel_Lattice - Fatal编程技术网

R 使用不同数据的格中的面板函数

R 使用不同数据的格中的面板函数,r,panel,lattice,R,Panel,Lattice,我正在使用一个名为d in R的数据框。我想使用两列绘制散点图,包括一条最佳拟合回归线,并绘制组合平均值。 我已经计算了箱子和装箱平均数的中心,并将它们作为列包含在数据框中。 我可以让散点图和回归线工作,但不能让装箱的方法显示出来。使用下面的代码,我没有得到任何错误,但是panel.points函数没有显示 scatter.Epsilon <- xyplot(Epsilon ~ data.subset.UpdatedVS30.091015,

我正在使用一个名为d in R的数据框。我想使用两列绘制散点图,包括一条最佳拟合回归线,并绘制组合平均值。 我已经计算了箱子和装箱平均数的中心,并将它们作为列包含在数据框中。 我可以让散点图和回归线工作,但不能让装箱的方法显示出来。使用下面的代码,我没有得到任何错误,但是panel.points函数没有显示

    scatter.Epsilon <- xyplot(Epsilon ~ data.subset.UpdatedVS30.091015,
                      data = d,
                      grid = TRUE,
                      scales = list(x = list(log = 10)),
                      xlab = "Vs30 (m/s)",
                      ylab = "Epsilon",
                      ylim = c(-4, 3),
                      xlim = c(10^2,10^3.4),
                      subscripts = TRUE,
                      panel=function(x,y,subscripts,...) {
                        panel.xyplot(x,y) 
                        panel.abline(mod <- lm(y ~ x), col = 'black')
                        panel.points(d$bin.ep[subscripts], d$means.ep[subscripts],
                                     col = 'red')})
                      scatter.Epsilon

scatter.Epsilon我认为您可能试图在调用panel.points时做太多的工作。使用您的示例数据,此代码运行良好:

scatter.Epsilon <- xyplot(dist ~ x,
                      data = d,
                      grid = TRUE,
                      subscripts = TRUE,
                      panel=function(x,y,subscripts,...) {
                        panel.xyplot(x,y) 
                        panel.abline(mod <- lm(y ~ x), col = 'black')
                        panel.points(bin,mean,col = 'red')})

公式中没有分组变量,因此不需要下标

您能提供一些生成数据帧d的代码吗?还是同样结构的东西?data.subset是d的一个组成部分还是其他东西?我用一个简化的数据框更新了我的原始问题-希望这能有所帮助。data.subset.UpdatedVS30.091015是d的一个组件,$最初是一个输入错误。谢谢。谢谢-这个简化的例子对我也很有用。但是,在我的原始代码中使用简化的panel.points参数并不能解决问题。不明白为什么不!可能使用dput发布数据帧d的随机样本,而不是虚构的样本。
scatter.Epsilon <- xyplot(dist ~ x,
                      data = d,
                      grid = TRUE,
                      subscripts = TRUE,
                      panel=function(x,y,subscripts,...) {
                        panel.xyplot(x,y) 
                        panel.abline(mod <- lm(y ~ x), col = 'black')
                        panel.points(bin,mean,col = 'red')})
panel.points(bin.ep,means.ep,col='red')