> 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, Sa
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 <- subset(sc
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 <- sub
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 variable
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 =
c("pass",
er
Clinical Research Support Unit
College of Medicine
University of Saskatchewan
On 12/18/2014 9:16 AM, David L Carlson wrote:
Depending on what you want, you probably want to start with expand.grid():
# All combinations of test with test
pairs1 <- expand.grid(test, test)
nrow(pairs1)
[1] 36
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 time
logy
Texas A&M 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 vectors
I can
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 wrote:
> Hi all,I am looking for a functio
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 permutatio
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)),
re. 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 columns
I have data that looks like this:
Friend1, Frien
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 <- rbi
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 combination
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)
>
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
quot;
#or
paste("(",as.vector(outer(T1,T2,paste,sep=",")),")",sep="")
#[1] "(c1,k1)" "(c2,k1)" "(c3,k1)" "(c4,k1)" "(c5,k1)" "(c1,k2)" "(c2,k2)"
#[8] "(c3,k2)" "(c4,k2)"
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
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)
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 excee
AM
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/mail
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 http:
Hi,
On Tue, Oct 5, 2010 at 3:52 AM, Trying To learn again
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
>
> NC[price(i,j)=="1" & price(i,j)=
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-requis
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 l
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 pla
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
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,
Jorg
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 available
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á
> Thank you for the quick answer, but i was asking if some method could do
> combinations where numbers of the sa
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
> Hi Cláudio,
>
> Try t
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
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 d
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 http://www.
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
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 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
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 = "
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 :
>
> Dear R helpers,
>
> I am working on the scenario analysis pertaining to various interest rates.
>
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,
Dear Amelia,
On 12/4/09, Amelia Livington 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 respective probabiliti
Â
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 p
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 wrote:
> Hi All, some help on
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 del
body of
data.
~ 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 a
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, fo
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 an
50 matches
Mail list logo