On 21.12.2011 14:39, Keith Jewell wrote:
OK, someone point it out to me; my wife tells me I can't see what's in front
of me :-}
I read ?expand.grid carefully, went to ?combn and ?choose but still couldn't
see an easy way to get what the OP asked for. The neatest I can get (which
isn't very neat!) is:
myVec<- c(1,2,3)
eg<- expand.grid(myVec, myVec)
eg[eg[,1]<= eg[,2],]
Var1 Var2
1 1 1
4 1 2
5 2 2
7 1 3
8 2 3
9 3 3
What am I missing?
You are just using a different order - sort accoriding to Var1...
Best,
Uwe Ligges
Best regards,
KJ
"Jeff Newmiller"<jdnew...@dcn.davis.ca.us> wrote in message
news:80cc9ff9-d867-4dfc-b6e3-9c1df7822...@email.android.com...
You could read the help for expand.grid very carefully for the answer to
this question.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go
Live...
DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live
Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#.
rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Antje Niederlein<niederlein-rs...@yahoo.de> wrote:
Hi there,
I have a vector and would like to create a data frame, which contains
all unique combination of two elements, regardless of order.
myVec<- c(1,2,3)
what expand.grid does:
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3
what I would like to have
1,1
1,2
1,3
2,2
2,3
3,3
Can anybody help?
______________________________________________
R-help@r-project.org mailing list
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.
______________________________________________
R-help@r-project.org mailing list
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.
______________________________________________
R-help@r-project.org mailing list
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.