[R] Programing and writing function help
erinm.hodgess at gmail.com
Wed Oct 8 13:07:00 CEST 2008
Actually, you will have duplicates with 400 pairs.
Here you will have 13^2 pairs with replacement and 13*12 pairs without
replacement and with regard to order.
How about this:
> z <- unique(x)
> y <- expand.grid(z[1:13],z[1:13])
> xx <- y[,1] != y[,2]
Just another thought.
On Wed, Oct 8, 2008 at 5:55 AM, Erin Hodgess <erinm.hodgess at gmail.com> wrote:
> For all possible pairs, you'll have 20^2 pairs.
> This is a way to do it:
> On Wed, Oct 8, 2008 at 4:43 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
>> Stephen Cole wrote:
>>> I have a vector of 20 values
>>> x <- c(20,18, 45, 16, 47, 47, 15, 26, 14,14,12,16,35,27,18,94,16,26,26,30)
>>> I want to select random pairs from this data set but do it without
>>> replacement exhaustively
>> then step through the columns of the resulting matrix
>>> I know i can select random pairs without replacement using
>>> However i am wondering if there is any way to get 10 random pairs from
>>> data set without repeating any of the data points
>>> that is to say if i got a (20, 94) for one pair, i would like to get 9
>>> pairs from the data without again getting 20 or 94?
>>> The second thing i would like to do is be able to select all possible
>>> of numbers and calculate each pairs variance.
>> I think you want to use the combn function, but you are going to get a lot
>> of pairs...
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com
More information about the R-help