rdata-visualizationheatmaplatticelevelplot

Unused argument in layer_


I am trying to reproduce the following here:

https://www.r-graph-gallery.com/201-levelplot-with-latticeextra.html

# library
library(latticeExtra) 
 
# create data
set.seed(1) 
data <- data.frame(x = rnorm(100), y = rnorm(100)) 
data$z <- with(data, x * y + rnorm(100, sd = 1)) 
 
# showing data points on the same color scale 
levelplot(z ~ x * y, data, 
          panel = panel.levelplot.points, cex = 1.2
    ) + 
    layer_(panel.2dsmoother(..., n = 200))

But I am getting

Error in layer(panel.2dsmoother(..., n = 200), under = TRUE) : unused argument (under = TRUE)

This was working fine yesterday, I am not sure what happened?


Solution

  • If you loaded another package that has a function called layer, it will mask this function in latticeExtra. There are numerous packages with a layer function.

    You can either restart your R session as suggested by Allan and only load the package(s) you need. Or, you can tell R which layer function you want:

    levelplot(z ~ x * y, data, 
              panel = panel.levelplot.points, cex = 1.2
             ) + 
      latticeExtra::layer_(panel.2dsmoother(..., n = 200))