I am trying to construct a data frame in expand.grid with two columns: pd and ph where the variables range between 0 and 1 in increments of 0.005 and pd + ph is less than one.

Here is my code thus far:

pd <- seq(from = 0, to = 1, by = .005)

ph <- seq(from = 0, to = 1, by = .005)

z <- pd + ph

datatime <- data.frame(x = pd, y = ph, z = z)

newdata <- datatime[datatime$z < 1,]

expand.grid(newdata$x,newdata$y)

The problem is that I am supposed to get 20,100 results but here I am only getting 10,000 and clearly the subsetting is excluding more observations than I want it too...it appears to be getting rid of any observations with a z-value greater than 1/2. Any thoughts?

0 Answers