[R] Sampling problem

wangwallace talenttree at gmail.com
Mon Nov 15 21:59:21 CET 2010


Hey,

I am hoping someone can help me with a sampling question.

I have a data frame of 8 variables (the first column is the subjects' id):

    SubID    CSE1 CSE2 CSE3 CSE4 WSE1 WSE2 WSE3 WSE4 
      1          6      5       6       2      6      2        2       4
      2          6      4       7       2      6      6        2       3
      3          5      5       5       5      5      5        4       5
      4          5      4       3       4      4      4        5       2
      5          5      6       7       5      6      4        4       1
      6          5      4       3       6      4      3        7       3
      7          3      6       6       3      6      5        2       1
      8          3      6       6       3      6      5        4       7 

the 6 variables are categorized into two groups with CSE1, CSE2, CSE3, and
CSE4 in one group and the rest in another group. 

>sample(data[,2:4],2,replace=FALSE)
     
   CSE1 CSE2 
1      6    5    
2      6    4   
3      5    5   
4      5    4    
5      5    6   
6      5    4    
7      3    6    
8      3    6    

Now I want to sample 1 column from another group of variables (i.e., WSE1,
WSE2, WSE3, WSE4), but I want to restrict a vector I am going to sample from
to only those columns that are not correspond to GROUP 1 variables I have
sampled. That is, I want to sample a column from WSE3, WSE4  Columns  
corresponding to CSE1 and CSE2 (i.e., WSE1, WSE2) need to be dropped. 

How can I do this? what if I want to repeat this whole process (drawing 2
random columns from CSE1, CSE2, CSE3, and CSE4 first, AND then another
random column from WSE1, WSE2, WSE3, and WSE4) for 1000 times. any ideas?

Many thanks in advance!!

-- 
View this message in context: http://r.789695.n4.nabble.com/Sampling-problem-tp3043804p3043804.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list