> Given that clarification, I'd just generate the full set and remove
> the ones you aren't interested in, as in:
I'd agree; that is probably the most efficient thing to do with only half a
dozen binary variables and a single condition.
A way of going about it for a more complex case might be to
Logic:
!(E == "fail" & F == "fail) <==>
(E == "pass" | F == "pass")
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Aug 2, 2018 at 8:57 AM,
Given that clarification, I'd just generate the full set and remove
the ones you aren't interested in, as in:
scenarios <- expand.grid(A = c("pass", "fail"), B = c("pass", "fail"), C =
c("pass", "fail"), D = c("pass", "fail"), E = c("pass", "fail"), F =
c("pass", "fail"))
scenarios <-
From what I can tell, the simplest way is to
First generate all the combinations
Then exclude those you don't want.
Here's an example, with only three variables (D, E, and F), that excludes those
where E and F both fail
> tmp <- c('p','f')
> X <- expand.grid(D=tmp, E=tmp, F=tmp)
> X <-
Thank you for pointing that out, I realize not only did I use the wrong
language but I did not describe the situation accurately. I do need to
address the situation where both variables E and F actually pass, that is
the majority case, one or the other can fail, but there can never be a
situation
> On Thu, Aug 2, 2018 at 11:20 AM, R Stafford
> wrote:
> > But I have the extra condition that if E is true, then F must be false, and
> > vice versa,
Question: Does 'vice versa' mean
a) "if E is False, F must be True"
or
b) "if F is True, E must be False"?
... which are not the same.
b) (and
Hi Rod,
How about this?
scenarios <- expand.grid(A = c("pass", "fail"), B = c("pass", "fail"), C =
c("pass", "fail"), D = c("pass", "fail"), E = c("pass", "fail"))
scenarios$F<-ifelse(scenarios$E=="pass","fail","pass")
Jim
On Thu, Aug 2, 2018 at 11:20 AM, R Stafford wrote:
> I have 6
I have 6 variables, (A,B,C,D,E,F) that can either pass or fail (i.e., true
or false).
I can get a table of all pass/fail combinations with this:
scenarios <- expand.grid(A = c("pass", "fail"), B = c("pass", "fail"), C =
c("pass", "fail"), D = c("pass", "fail"), E = c("pass", "fail"), F =
Hi all,I am looking for a function that would give me all the combinations
between two vectors.Lets take as example the
test-seq(1,3,by=5000)
Browse[2] test
[1] 1 5001 10001 15001 20001 25001
I want all the combinations between two times the test... I think this is
called permutation
I can't quite tell what you want: your example output is either
unclear to me or mangled by posting in HTML (please don't).
Is
expand.grid(test, test)
what you want, or partway to what you want?
Sarah
On Thu, Dec 18, 2014 at 9:56 AM, Alaios via R-help r-help@r-project.org wrote:
Hi all,I am
77840-4352
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sarah Goslee
Sent: Thursday, December 18, 2014 9:06 AM
To: Alaios
Cc: R-help@r-project.org
Subject: Re: [R] combinations between two vectors
I can't quite tell what you want: your example output
On 18/12/2014 14:56, Alaios via R-help wrote:
Hi all,I am looking for a function that would give me all the combinations
between two vectors.Lets take as example the
test-seq(1,3,by=5000)
Browse[2] test
[1] 1 5001 10001 15001 20001 25001
I want all the combinations between two times
Department of Anthropology
Texas AM University
College Station, TX 77840-4352
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sarah Goslee
Sent: Thursday, December 18, 2014 9:06 AM
To: Alaios
Cc: R-help@r-project.org
Subject: Re: [R] combinations between two
I have data that looks like this:
Friend1, Friend2
A, B
A, C
B, A
C, D
And I'd like to generate some more rows and another column. In the new
column I'd like to add a 1 beside all the existing rows. That bit's
easy enough.
Then I'd like to add rows for all the possible directed
You could use the data.table package
require(data.table)
DT - data.table(Friend1 = sample(LETTERS, 10, replace = TRUE), Friend2 =
sample(LETTERS, 10, replace = TRUE), Indicator = 1)
ALL - data.table(unique(expand.grid(DT)))
setkey(ALL)
OTHERS - ALL[!DT]
OTHERS[, Indicator := 0]
RESULT -
Mango Solutions
2 Methuen Park, Chippenham, Wiltshire. SN14 OGB UK
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Thomas
Sent: 01 November 2013 09:32
To: r-help@r-project.org
Subject: [R] Combinations of values in two
Hi,
You may try:
dat1 - read.table(text=
Friend1,Friend2
A,B
A,C
B,A
C,D,sep=,,header=TRUE,stringsAsFactors=FALSE)
indx - as.vector(outer(unique(dat1[,1]),unique(dat1[,2]),paste))
res -
cbind(setNames(read.table(text=indx,sep=,header=FALSE,stringsAsFactors=FALSE),paste0(Friend,1:2)),
Hi every one,
I have two sets T1={c1,c2,..,cn} and T2={k1,k2,...,kn}.
How can I find the sets as follow:
(c1,k1), (c1,k2) ...(c1,kn) (c2,k1) (c2,k2) (c2,kn) ... (cn,kn)
Thanks.
Amir
--
__
Amir Darehshoorzadeh
...@uottawa.ca
To: r-help@r-project.org
Cc:
Sent: Friday, March 15, 2013 9:22 AM
Subject: [R] Combinations
Hi every one,
I have two sets T1={c1,c2,..,cn} and T2={k1,k2,...,kn}.
How can I find the sets as follow:
(c1,k1), (c1,k2) ...(c1,kn) (c2,k1) (c2,k2) (c2,kn) ... (cn,kn)
Thanks.
Amir
At Fri, 15 Mar 2013 09:22:15 -0400,
Amir wrote:
I have two sets T1={c1,c2,..,cn} and T2={k1,k2,...,kn}.
How can I find the sets as follow:
(c1,k1), (c1,k2) ...(c1,kn) (c2,k1) (c2,k2) (c2,kn) ... (cn,kn)
I think you are looking for expand.grid:
expand.grid(1:3, 10:13)
Var1 Var2
1
Is
?expand.grid
what you are looking for?
Rgds,
Rainer
On Friday 15 March 2013 09:22:15 Amir wrote:
Hi every one,
I have two sets T1={c1,c2,..,cn} and T2={k1,k2,...,kn}.
How can I find the sets as follow:
(c1,k1), (c1,k2) ...(c1,kn) (c2,k1) (c2,k2) (c2,kn) ... (cn,kn)
I am trying to make a function permute that takes two arguments: 1)
and alphabet consisting of a set of symbols and 2) a length being a
single integer N.With a safety check check in permute() that stops
execution (use the stop() function) with a warning when the number of
permutations would exceed
On 29-04-2012, at 13:09, Melinda Harwood wrote:
I am trying to make a function permute that takes two arguments: 1)
and alphabet consisting of a set of symbols and 2) a length being a
single integer N.With a safety check check in permute() that stops
execution (use the stop() function) with
any idea how to get R to compute a combination like (54323456, 2345) ?
--
Thanks,
Jim.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
To: r-help@r-project.org
Subject: Re: [R] Combinations
any idea how to get R to compute a combination like (54323456, 2345) ?
--
Thanks,
Jim.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman
Hi all,
Reading more I have find a partial solution on a part of the proble in some
part of the code it should appea something like:
# NC: All the potential combinations 3^15
if
NC[price(i,j)==1 price(i,j)==2] extract this column
then save all the columns that contain this pre-requisite.
Hi,
On Tue, Oct 5, 2010 at 3:52 AM, Trying To learn again
tryingtolearnag...@gmail.com wrote:
Hi all,
Reading more I have find a partial solution on a part of the proble in some
part of the code it should appea something like:
# NC: All the potential combinations 3^15
if
Hi all,
I´ve been ill and I have lost a lot of time without seen the pc.
I want you to help if you can if you want.
Only I need an initial guide. I´ve been out a lot of time and I need a hope.
Is only for joby purposes.
The problem:
I want to simulate each of the posible combination in a
Dear ,
15 is very big number for me (perhaps for R as well :() so I have tried
following:
mat - expand.grid(rep(list(c(1, X, 2)),4)); mat[mat[,3]==2,]
--
View this message in context:
http://r.789695.n4.nabble.com/Combinations-tp2955065p2955338.html
Sent from the R help mailing list
I would appreciate any suggestions on which function to use to write subsequent
functions analysing combinations of treatments.
This refers to experimental trials of medical treatments. I want to write
routines to analyse various comparisons (combinations)
So if 5 treatments are
Hi Jim,
How about expand.grid()?
expand.grid(c('t01','t02','t03','t04','t05'), 't04')
Var1 Var2
1 t01 t04
2 t02 t04
3 t03 t04
4 t04 t04
5 t05 t04
expand.grid(c('t01','t02','t03','t04','t05'), 't01')
Var1 Var2
1 t01 t01
2 t02 t01
3 t03 t01
4 t04 t01
5 t05 t01
HTH,
Jorge
one possibility is:
treats - t(combn(c(t01, t02, t03, t04, t05), 2))
treats
# extract only t04
treats[apply(treats == t04, 1, any), ]
I hope it helps.
Best,
Dimitris
On 8/18/2010 1:44 PM, Maas James Dr (MED) wrote:
I would appreciate any suggestions on which function to use to write
Hi once again.
just to let you know that i found the answer i need:
http://www.mail-archive.com/r-help@r-project.org/msg65359.html
Thank you once more.
Cláudio
2010/4/24 Cláudio Sá c0870...@alunos.fc.up.pt
Thank you for the quick answer, but i was asking if some method could do
combinations
Thank you for the quick answer, but i was asking if some method could do
combinations where numbers of the same vector wont combine.
A little bit like 'expand.grid', but with the possibility to choose the
length for output combinations.
Cláudio
2010/4/23 Jorge Ivan Velez jorgeivanve...@gmail.com
Hi!
Is there any easy/fast way to combine vectors with restrictions?
Example:
a=c(1,2,3), b=c(4,5,6), c=c(7,8,9)
I want all combinations of this 3 vectors with length=2.
Like this:
1,4
1,5
1,6
1,7
1,8
1,9
2,4
2,5
2,6
2,7
... and so on.
Thanks in advance.
[[alternative HTML version
Hi Cláudio,
Try this:
require(gtools)
combinations(10, 2)
combinations(10, 2, repeats = TRUE)
HTH,
Jorge
2010/4/23 Cláudio Sá
Hi!
Is there any easy/fast way to combine vectors with restrictions?
Example:
a=c(1,2,3), b=c(4,5,6), c=c(7,8,9)
I want all combinations of this 3 vectors
For a package application, I want to generate all 1-way, or 2-way, ...
combinations of factors, symbolically, as a matrix.
E.g., all two-way terms among 4 factors.
factors - LETTERS[1:4]
combn(4,2)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]111223
[2,]2343
res - combn(4,2)
result - LETTERS[res]
dim(result) - dim(res)
result
## Rich
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
Dear all,
I have a table like this:
a - read.csv(test.csv, header = TRUE, sep = ;)
a
UTM pUrb pUrb_class pAgri
pAgri_class pNatFor pNatFor_class
1 NF188520.160307 NA 79.921386NA
Dear all,
I have the following dataset:
t - structure(list(pUrb = c(20.160307, 51.965649, 26.009581, 3.141484,
64.296826
), pUrb_class = structure(c(1L, 1L, 1L, 1L, 1L), .Label = c(0,
1), class = factor), pAgri = c(79.921386, 46.657713,
40.269204, 0, 0.440691), pAgri_class =
Dear R helpers,
I am working on the scenario analysis pertaining to various interest rates. In
this connection I need to form the various combinations as under :
Suppose I have two sets A = (a, b, c) and B = (x,y,z)
Then I can easily form the cominations as
(ax, ay, az, bx, by, bz, cx, cy,
Hi,
Try this,
apply(expand.grid(letters[1:3], letters[24:26]), 1, paste,collapse=)
[1] ax bx cx ay by cy az bz cz
?expand.grid
HTH,
baptiste
2009/12/14 Amelia Livington amelia_living...@yahoo.com:
Dear R helpers,
I am working on the scenario analysis pertaining to various interest rates.
On 12/14/2009 10:50 AM, baptiste auguie wrote:
Hi,
Try this,
apply(expand.grid(letters[1:3], letters[24:26]), 1, paste,collapse=)
[1] ax bx cx ay by cy az bz cz
This will be faster, as it takes advantage of the vectorized paste:
cpaste - function(...) paste(..., sep = )
do.call( cpaste,
Â
Dear R helpers
Â
Suppose I have two sets of ranges (interest rates) as
Â
Range 1 : (7 â 7.50, 7.50 â 8.50, 8.50 â 10.00) with respective
probabilities 0.42, 0.22 and 0.36.
Â
Â
Range II : (11-12, 12-14, 14-21) with respective probabilities 0.14, 0.56 and
0.30 respectively.
Â
Â
My
Dear Amelia,
On 12/4/09, Amelia Livington amelia_living...@yahoo.com wrote:
Dear R helpers
Suppose I have two sets of ranges (interest rates) as
Range 1 : (7 – 7.50, 7.50 – 8.50, 8.50 – 10.00) with respective
probabilities 0.42, 0.22 and 0.36.
Range II : (11-12, 12-14, 14-21) with
Hi All, some help on this would be appreciated;
Understood combinations(7,4) returns all the possible 4 part combinations
out of 7. Is is possible to substitute the ³7² for a list of stuff you would
like to see the mix of; c(³a²,...,²g²) say ?
Thanks
Glenn
[[alternative HTML version
Dear Glenn,
Try this:
# Your example
choose(7,4)# 35
require(forward)
fwd.combn(7,4) # a 4x35 matrix
# Other possibilities
sapply(4:10,function(x) choose(x,4))
sapply(4:10,function(x) fwd.combn(x,4))
HTH,
Jorge
On Sun, Jan 18, 2009 at 6:06 PM, glenn g1enn.robe...@btinternet.com
Dear all,
Is there a way to compute and list all combinations with replication of two
elements in sets of 8 elemnts?
For example, I've two elements, 0 and 1, and I would to get all possible
combinations with replication such as, for example, , 0001,
0010, and so on. They are 2^8
On Thu, 2008-07-31 at 02:29 -0700, MarinaTarantini wrote:
Dear all,
Is there a way to compute and list all combinations with replication of two
elements in sets of 8 elemnts?
For example, I've two elements, 0 and 1, and I would to get all possible
combinations with replication such as, for
.
~ John Tukey
-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Jim Lemon
Verzonden: donderdag 31 juli 2008 13:19
Aan: MarinaTarantini
CC: r-help@r-project.org
Onderwerp: Re: [R] combinations with replications
On Thu, 2008-07-31 at 02:29 -0700, MarinaTarantini
50 matches
Mail list logo