... and actually, since u can be assumed to be of the form shown,
v <-do.call(expand.grid, split(rep(u,len),rep(u,e=len)))
should do.
-- Bert
On Thu, Nov 7, 2013 at 10:06 AM, Bert Gunter wrote:
> Well, you can create the expand.grid data frame programmatically via:
>
> u <- 1:3
> len <- lengt
Well, you can create the expand.grid data frame programmatically via:
u <- 1:3
len <- length(u)
v <-do.call(expand.grid, split(rep(u,len),rep(seq_len(len),e=len)))
And then you can use unique.array to get the unique rows after the sort:
unique(t(apply(v,1,sort)))
However, I agree with your sent
On 07-Nov-2013 13:38:29 Konstantin Tretiakov wrote:
> Hello!
>
> I need to obtain all possible combinations with replacement when
> order is not important.
> E.g. I have a population x{1,2,3}.
> So I can get (choose(3+3-1,3)=) 10 combinations from this population
> with 'size=3'.
> How can I get a
retiakov
> Sent: Thursday, November 07, 2013 5:38 AM
> To: r-help@r-project.org
> Subject: [R] all combinations with replacement not ordered
>
> Hello!
>
> I need to obtain all possible combinations with replacement when order is
> not important.
> E.g. I have a populatio
Hello!
I need to obtain all possible combinations with replacement when order is
not important.
E.g. I have a population x{1,2,3}.
So I can get (choose(3+3-1,3)=) 10 combinations from this population with
'size=3'.
How can I get a list of all that combinations?
I have tried 'expand.grid()' and ma
Leaps works :)
Thanks a lot!
JMF
-
Jean-Michel Fortin
Étudiant au premier cycle en Biologie/ Undergraduate in Biology
Lab Currie Université d'Ottawa/ Currie Lab University of Ottawa
--
View this message in context:
http://r.789695.n4.nabble.com/All-combinations-possible-in-a-mutliple-reg
Look at the leaps function in the leaps package. It will compute the
Cp statistic which is a function of AIC.
On Thu, Aug 9, 2012 at 7:28 AM, zel7223 wrote:
> Hi,
>
> I want to use four independent variables to predict the output of one
> dependent variable using a linear model lm. I want to com
9852
A.K.
- Original Message -
From: zel7223
To: r-help@r-project.org
Cc:
Sent: Thursday, August 9, 2012 9:28 AM
Subject: [R] All combinations possible in a mutliple regression
Hi,
I want to use four independent variables to predict the output of one
dependent variable using a linear mo
DF, p-value: 0.7732
A.K.
- Original Message -
From: zel7223
To: r-help@r-project.org
Cc:
Sent: Thursday, August 9, 2012 9:28 AM
Subject: [R] All combinations possible in a mutliple regression
Hi,
I want to use four independent variables to predict the output of one
dependent variab
Try a look at this:
http://stat.ethz.ch/R-manual/R-patched/library/MASS/html/stepAIC.html
Regards,
Phil
--
View this message in context:
http://r.789695.n4.nabble.com/All-combinations-possible-in-a-mutliple-regression-tp4639762p4639782.html
Sent from the R help mailing list archive at Nabble.
Hi,
I want to use four independent variables to predict the output of one
dependent variable using a linear model lm. I want to compare all possible
combinations of the 4 independent variables, including singles, pairs and
triples.
I was thinking of using the AIC test to compare all models and pi
On Nov 30, 2011, at 7:18 AM, R. Michael Weylandt wrote:
expand.grid()
This one is admittedly rather hard to find...
Well, it is linked from the `combn` help page. And it is the likely to
be first or second in a search with ??combinations since it is in
pkg:base and at least on my interfa
expand.grid()
This one is admittedly rather hard to find...
Michael
On Nov 30, 2011, at 7:15 AM, Alaios wrote:
> Dear all,
> I would like something simple to do in R that I do not know how I should
> search for it.
>
> Let's say that I have a list of
> a<-c(1,2,3,4,5)
> b<-(6,7,8)
> and I wa
Dear all,
I would like something simple to do in R that I do not know how I should search
for it.
Let's say that I have a list of
a<-c(1,2,3,4,5)
b<-(6,7,8)
and I want to get back all their possible cominations like
1,6
1,7
1,8
2,6
2,7
2,8
3,6
3,7
3,8
and so on.
How I can do that?
B.R
Alex
rom: Petr PIKAL [mailto:petr.pi...@precheza.cz]
Sent: 29 August 2011 07:24
To: Campbell, Desmond
Cc: r-help@R-project.org
Subject: Odp: [R] all combinations of the elements of two vectors
Hi
Dear R-help readers,
I'm sure this problem has been answered but I can't find the
solution.
I have t
use it to reconfigure the matrix's shape
to any that contains the same number of elements.
Thanks very much one and all.
Regards
Desmond
-Original Message-
From: Petr PIKAL [mailto:petr.pi...@precheza.cz]
Sent: 29 August 2011 07:24
To: Campbell, Desmond
Cc: r-help@R-project.org
Subjec
11 19:19
To: Campbell, Desmond
Cc: r-help@R-project.org
Subject: Re: [R] all combinations of the elements of two vectors
Hi Desmond,
You might try
> sort(apply(expand.grid(v1, v2), 1, paste, collapse = "", sep = ""))
[1] "a1" "a2" "a3" &qu
x<-letters[1:3]
y<-1:3
d<-expand.grid(x,y)
g<-apply(d,1,function(x) paste(x[1],x[2],sep=""))
HTH,
Daniel
Campbell, Desmond-2 wrote:
>
> Dear R-help readers,
>
> I'm sure this problem has been answered but I can't find the solution.
>
> I have two vectors
> v1 <- c("a","b")
> v2 <- c(1,2,3)
Hi Desmond,
You might try
> sort(apply(expand.grid(v1, v2), 1, paste, collapse = "", sep = ""))
[1] "a1" "a2" "a3" "b1" "b2" "b3"
HTH,
Jorge
On Sat, Aug 27, 2011 at 12:54 PM, Campbell, Desmond <> wrote:
> Dear R-help readers,
>
> I'm sure this problem has been answered but I can't find the so
Dear R-help readers,
I'm sure this problem has been answered but I can't find the solution.
I have two vectors
v1 <- c("a","b")
v2 <- c(1,2,3)
I want an easy way to produce every possible combination of v1, v2 elements
Ie I want to produce
c("a1","a2","a3", "b1","b2","b3")
regards
Desmond
Desmo
> Sent: Thursday, April 21, 2011 12:29 PM
> To: r-help@r-project.org
> Subject: [R] all combinations with replacement
>
> Dear all,
>
> is there an easy way to get all possible combinations (?)
> with replacement.
> If n=6, k=3, i want something like
>
> 0 0 6
>
On Thu, Apr 21, 2011 at 12:52:34PM -0700, Kehl Dániel wrote:
> Thank you.
> I only need those where the rowsum = n.
> I could choose those with code, but I dont think it is efficient that way.
Efficiency of using expand.grid() may be improved, if expand.grid()
is used only to k-1 columns, then the
Hi Kehl,
How large are n and k in your case? Using Dimitris' approach and I got the
following timings for 1000 replicates:
# function based on Dimitri's reply
foo <- function(n, k){
r <- expand.grid(rep(list(0:n), k))
subset(r, rowSums(r) == n)
}
# a second try
foo2 <- function(n
Thank you.
I only need those where the rowsum = n.
I could choose those with code, but I dont think it is efficient that way.
daniel
2011-04-21 12:33 keltezéssel, Dimitris Rizopoulos írta:
expand.grid(rep(list(0:6), 3))
__
R-help@r-project.org mai
probably expand.grid(), e.g.,
expand.grid(rep(list(0:6), 3))
I hope it helps.
Best,
Dimitris
On 4/21/2011 9:28 PM, Kehl Dániel wrote:
Dear all,
is there an easy way to get all possible combinations (?) with replacement.
If n=6, k=3, i want something like
0 0 6
0 5 1
0 4 2
0 3 3
0 2 4
.
.
Dear all,
is there an easy way to get all possible combinations (?) with replacement.
If n=6, k=3, i want something like
0 0 6
0 5 1
0 4 2
0 3 3
0 2 4
.
.
.
5 0 1
5 1 0
6 0 0
I tried to look at combn() but I could not get this done with it.
Thank you in advance:
Daniel
___
26 matches
Mail list logo