[R] lattice question

Naresh Gurbuxani n@re@h_gurbux@n| @end|ng |rom hotm@||@com
Wed Aug 10 13:18:56 CEST 2022


I want to merge two panels into one.  Is it possible to do this?

Thanks,
Naresh

library(lattice)
mydf <- data.frame(date = rep(seq.Date(as.Date("2022-08-01"), by = 1,
length.out = 10), 2), name = c(rep("Aa", 10), rep("Bb", 10)),
long = runif(20, 2, 10), short = runif(20, -10, 0))

# This plots data in two panels.  I want all four lines in one panel. 
xyplot(long + short ~ date, groups = name, data = mydf, type = c("l",
"g"))

# This does not work
# No error in R session
# Graph window says: "Error using packet 1
# argument 'subscripts' is missing, with no default"
xyplot(long ~ date, data = mydf, groups = name, type = c("l", "g"),
panel = function(x, y, ..., subscripts) {
  panel.xyplot(x, y, ...)
  panel.xyplot(mydf$date[subscripts], mydf$short[subscripts], ...)})



More information about the R-help mailing list