[R] Conditional expand.grid()
Hesen Peng
hesen.peng at emory.edu
Sat Jul 11 15:23:05 CEST 2009
Hello my R buddies,
I'm trying to generate a bivariate data.frame with the elements of
first row greater than the second row. The more complicated method
that I can think of is:
n <- 10
temp <- expand.grid(1:n,1:n)
temp<-temp[temp[,1]>temp[,2],]
However, I guess there must be some easier way of doing this. Besides,
if inequality condition is applied at the very beginning, this will
save me a lot of memory if n goes to a very large number. Is there any
suggestions? Thanks a lot.
Best wishes,
--
彭河森 Hesen Peng
http://hesen.peng.googlepages.com/
More information about the R-help
mailing list