>From the "densregion" help page I can read that:

z is a matrix of densities on the grid defined by x and y,
with rows corresponding to elements of x
and columns corresponding to elements of y.

So in your scenario z must be a 3 rows x 100 columns matrix, if you like to
take advantage of densregion().

z cannot be a data frame, otherwise you get the error you mentioned.

Run this to verify.

require(denstrip)
set.seed(11)

x <- 0:2
nx <- length(x)
y <- seq(0, 1, length=100)
ny <- length(y)

# z is a matrix
z <- matrix(nrow=nx, ncol=ny)
for(i in 1:nx)
  z[i,] <- dnorm(y, 0, 1)

dim(z)
class(z)

# works
plot(x, type="n", ylim=c(-1, 1))
densregion(x, y, z, colmax="darkgreen")

# does not work
z.df <- data.frame(z)
densregion(x, y, z.df, colmax="darkgreen")

Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = 
decreasing)) :
  undefined columns selected


--
GG


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to