Adrian Dusa wrote:
> On Thursday 15 November 2007, [EMAIL PROTECTED] wrote:
>
>> Actually, (now that I know about combn), a better way is
>>
>> t(matrix(set[combn(7,2)], nrow = 2))
>>
>
> Indeed, or to avoid transposing:
>
> matrix(set[combn(7,2)], ncol = 2, byrow=T)
>
> Adrian
>
>
Or ev
Hi Haris,
On Thursday 15 November 2007, Charilaos Skiadas wrote:
> I must be missing something. What's wrong with:
>
> combn(set, 2)
>
> or if we must t(combn(set,2)), optionally with a function argument in
> the combn call if something is to be done with the pairs?
>
> So if you really wanted the
On Friday 16 November 2007, Peter Dalgaard wrote:
> [...]
>
> Or even (from someone who have known about combn for a while)
>
> > combn(LETTERS[1:7], 2, paste, collapse="")
>
> [1] "AB" "AC" "AD" "AE" "AF" "AG" "BC" "BD" "BE" "BF" "BG" "CD" "CE"
> "CF" "CG"
> [16] "DE" "DF" "DG" "EF" "EG" "FG"
Ch
quot;D" "F"
> [18,] "D" "G"
> [19,] "E" "F"
> [20,] "E" "G"
> [21,] "F" "G"
>
>
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Ph
On Thursday 15 November 2007, [EMAIL PROTECTED] wrote:
> Actually, (now that I know about combn), a better way is
>
> t(matrix(set[combn(7,2)], nrow = 2))
Indeed, or to avoid transposing:
matrix(set[combn(7,2)], ncol = 2, byrow=T)
Adrian
--
Adrian Dusa
Romanian Social Data Archive
1, Schitu Ma
-project.org
Subject: Re: [R] generate combination set
Using your "set", wouldn't it be simpler like this?
t(apply(combn(7,2), 2, function(x) set[x]))
Hth,
Adrian
On Thursday 15 November 2007, [EMAIL PROTECTED] wrote:
> There are a number of packages that do this, but here is a sim
"D" "E"
>> [17,] "D" "F"
>> [18,] "D" "G"
>> [19,] "E" "F"
>> [20,] "E" "G"
>> [21,] "F" "G"
>>
>>
>> Bill Venables
>>
"G"
[19,] "E" "F"
[20,] "E" "G"
[21,] "F" "G"
Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary): +61 7 3826 7304
Mobile:
I have a set data={A,B,C,D,E,F,G}
I want to choose 2 letter from 8 letters, i.e. generate the combination set
for choose 2 letters from 8 letters.
I want to get the liking:
combination set={AB,AC,AD,}
Does anyone konw how to do in R.
thanks,
Aimin
___
9 matches
Mail list logo