[R] use sample function to create new data frame

wangwallace talenttree at gmail.com
Sun Nov 21 03:40:42 CET 2010


here is my original data frame

       a   b  c   A  B   C
[1,]  1   2  3   4  5   6
[2,]  7   8  9  10 11 12
[3,] 13 14 15 16 17 18

a, b, c are type I variables
A, B, C are type II variables

how can I create a new data frame in which:

1) in each row, there are one random number from type I variables, and two
random numbers from type II variables

2) meanwhile, in each row, the two type II numbers have to be only those
numbers that are not corresponding to the type I number. For example, if the
type I number is 1, the type II numbers should not include 4. 

the new data frame should be like this:

       [,1] [,2] [,3]
[1,]    I     II    II
[2,]    I     II    II
[3,]    I     II    II

Many thanks!! :)

-- 
View this message in context: http://r.789695.n4.nabble.com/use-sample-function-to-create-new-data-frame-tp3052110p3052110.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list