Re: [R] combination

2017-04-12 Thread Jeff Newmiller
?expand.grid -- Sent from my phone. Please excuse my brevity. On April 12, 2017 6:28:24 PM PDT, Val wrote: >Hi all, >I have two variables x and y. X has five observation and y has three. >I want combine each element of x to each element of y values to >produce 15 observation. Below is my sampl

Re: [R] combination

2017-04-12 Thread Bert Gunter
Is this homework? We don't do homework here. -- 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 Wed, Apr 12, 2017 at 6:28 PM, Val wrote: > Hi all, > I h

[R] combination

2017-04-12 Thread Val
Hi all, I have two variables x and y. X has five observation and y has three. I want combine each element of x to each element of y values to produce 15 observation. Below is my sample data and desired output data x Y 1 A 2 B 3 C 4 5 Output 1 A 1 B 1 C 2 A 2 B 2 C 3 A 3 B 3 C 4

Re: [R] combination of columns in a matrix

2013-06-14 Thread arun
Hi, sapply(colnames(m)[-ncol(m)],function(i) {x1<-cbind(m[,i],m[,ncol(m)]); length(which(x1[,1]!=0 & x1[,2]!=0))}) #A B C #2 1 2 A.K. - Original Message - From: Hermann Norpois To: r-help Cc: Sent: Friday, June 14, 2013 3:51 PM Subject: [R] combination of columns in a

[R] combination of columns in a matrix

2013-06-14 Thread Hermann Norpois
Hello, I have a matrix m and I want to know how often does 1 (or !0) simultanously appear in A and REF, B and REF, C and REF. So actually I wish to automate following expression: > length (which (m[,1]!=0&m[,4]!=0)) [1] 2 > length (which (m[,2]!=0&m[,4]!=0)) [1] 1 Thanks Hermann > m A B C

Re: [R] Combination that adds a value

2011-03-22 Thread Julio Rojas
Thx Petr. It worked likea charm. Regards. __ 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, re

Re: [R] Combination that adds a value

2011-03-21 Thread Petr Savicky
On Mon, Mar 21, 2011 at 04:08:50AM -0700, Julio Rojas wrote: > Dear all, I have three vectors "x<-1:n", "y<-1:m" and "z<-2:(n+m)". I need to > find all combinations of "x" and "y" that add up a given value of "z", e.g., > for "z==3" the combinations will be "list(c(1,2),c(2,1))". Dear Julio: T

[R] Combination that adds a value

2011-03-21 Thread Julio Rojas
Dear all, I have three vectors "x<-1:n", "y<-1:m" and "z<-2:(n+m)". I need to find all combinations of "x" and "y" that add up a given value of "z", e.g., for "z==3" the combinations will be "list(c(1,2),c(2,1))". Thanks in advance for your help.

Re: [R] combination value

2010-12-21 Thread David Winsemius
On Dec 21, 2010, at 9:23 AM, amir wrote: Hi every one, I want to calculate the combination function in R, the value not all the possible choices. I mean cmbn(5,2)=10. Is there any function unless using factorial? ?choose -- David Winsemius, MD West Hartford

Re: [R] combination value

2010-12-21 Thread Jorge I Velez
choose(5, 2) HTH, Jorge On Tue, Dec 21, 2010 at 9:23 AM, amir <> wrote: > Hi every one, > > I want to calculate the combination function in R, the value not all the > possible choices. > I mean cmbn(5,2)=10. > > Is there any function unless using factorial? > > Rega

[R] combination value

2010-12-21 Thread amir
Hi every one, I want to calculate the combination function in R, the value not all the possible choices. I mean cmbn(5,2)=10. Is there any function unless using factorial? Regards, Amir [[alternative HTML version deleted]] _

Re: [R] Combination

2009-02-17 Thread Dimitris Rizopoulos
Eik Vettorazzi wrote: Hi Dani, see ?combn . combn(1:50,2) gives you all combinations as matrix. you can do sth like apply(combn(1:50,2),2, paste, sep="", collapse="") note that you could simplify the above by combn(50, 2, paste, collapse = "") Best, Dimitris to get concatenated results.

Re: [R] Combination

2009-02-17 Thread Eik Vettorazzi
Hi Dani, see ?combn . combn(1:50,2) gives you all combinations as matrix. you can do sth like apply(combn(1:50,2),2, paste, sep="", collapse="") to get concatenated results. hth. Dani Valverde schrieb: Hello, I have a sequence of numbers: seq(1:50) and I would like to have all the possible c

Re: [R] Combination

2009-02-17 Thread Henrique Dallazuanna
Try this: apply(expand.grid(1:50, 1:50), 1, paste, collapse = '') On Tue, Feb 17, 2009 at 8:37 AM, Dani Valverde wrote: > Hello, > I have a sequence of numbers: > seq(1:50) > and I would like to have all the possible combinations with this numbers > without repeating any combination: > 11, 12, 1

[R] Combination

2009-02-17 Thread Dani Valverde
Hello, I have a sequence of numbers: seq(1:50) and I would like to have all the possible combinations with this numbers without repeating any combination: 11, 12, 13, ... ,22,23,24,... How can I do it? Best, Dani -- Daniel Valverde SaubĂ­ Grup de Biologia Molecular de Llevats Facultat de Veter

Re: [R] Combination with repetition

2008-08-15 Thread Charles C. Berry
On Fri, 15 Aug 2008, Jose Luis Aznarte M. wrote: Hi there! I can't find any information about creating combinations with repetitions in R. The function combn() does create combinations, but _without_ repetitions. Here is what I need to do: svIter <- 1000 xx <- matrix(rnorm(m*n), c(m, n))

Re: [R] Combination with repetition

2008-08-15 Thread Dimitris Rizopoulos
you could use something like the following: expand.grid(rep(list(1:3), 4)) I hope it helps. Best, Dimitris Jose Luis Aznarte M. wrote: Hi there! I can't find any information about creating combinations with repetitions in R. The function combn() does create combinations, but _without_ re

[R] Combination with repetition

2008-08-15 Thread Jose Luis Aznarte M.
Hi there! I can't find any information about creating combinations with repetitions in R. The function combn() does create combinations, but _without_ repetitions. Here is what I need to do: svIter <- 1000 xx <- matrix(rnorm(m*n), c(m, n)) sequence <- seq(range(xx)[1], range(xx)[2], length