[R] Two selections from Bag A

darnold dwarnold45 at suddenlink.net
Sun Aug 26 02:37:07 CEST 2012


All, I am looking at an example in Aliaga's Interactive Statistics. Bag A has
the following vouchers.

BagA <- c(-1000,10,10,10,10,10,10,
          10,20,20,20,20,20,20,30,
          30,40,40,50,60)

Bag B has the following vouchers.

BagB <- c(10,20,30,30,40,40,50,50,
          50,50,50,50,60,60,60,60,
          60,60,60,1000)

Two values are selected (from BagA or BagB) without replacement. In Table
1.1 on page 54 of the third edition, she lists all "Possible two values
selected" in columns one and two, the "Average of the two selected values"
in column three and "BAG A Numbers of way of selecting the two values" in
column four, and "BAG B Number of ways of selecting the two values" in
column five.

Here are the first few rows:

-1000       -1000     -1000     0     0
-1000             10      -495      7     0
-1000             20     -490       6     0
-1000            30      -485       2     0
-1000            40      -480       2     0
-1000            50      -475       1     0
-1000            60      -470       1     0
-1000       1000             0       0     0
      10           10           10     21     0
      10            20           15    42      1
...

She then condenses the data in Table 1.2 on page 55, the first column
holding "Average of the two selected values', the second column holding "BAG
A Number of ways of selecting the two values," and third column holding "BAG
B Number of ways of selecting the two values."

Here are a few sample rows:

-1000     0     0
  -495     7     0
  -490     6     0
....

Can anyone help show me an efficient way of creating these two tables?

Thanks.

David.      





--
View this message in context: http://r.789695.n4.nabble.com/Two-selections-from-Bag-A-tp4641327.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list