On Aug 26, 2012, at 8:28 AM, darnold wrote:

Here are the two tables from Aligaga. The first is table 1.1 and the second
is table 1.2.

http://r.789695.n4.nabble.com/file/n4641344/table1_1.jpg

My code from earlier today (that you have not included) showed you how to tabulate and construct the BagA entries. I actually did it by way of makine a dataframe from the names of the table and a counts column with the table. In Table 1.1 the two Bags combinations have been merge()-ed by their value columns.

> merge(BagAcombs, BagBcombs, by=1:2, all=TRUE)
      X1   X2 counts.x counts.y
1  -1000   10        7       NA
2  -1000   20        6       NA
3  -1000   30        2       NA
4  -1000   40        2       NA
5  -1000   50        1       NA
6  -1000   60        1       NA
7     10   10       21       NA
8     10   20       42        1
9     10   30       14        2
10    10   40       14        2
11    10   50        7        6
12    10   60        7        7
13    10 1000       NA        1
 .... Rest of  output deleted

That object was assigned to "Combs".
I made the labels numeric. NA values were set to 0.

> Combs$X1 <- as.numeric(as.character(Combs$X1))
> Combs$X2 <- as.numeric(as.character(Combs$X2))

Calculate and average:

> Combs$Average <- with( Combs, rowMeans(X1,X2) )


http://r.789695.n4.nabble.com/file/n4641344/table1_2.jpg

So the second table is aggregated (summed and sorted) by the distinct values in the average-column of the first. (The 7 A 10 x 50 values are added to the 12 A 20 x 40 values and the single 1 A 30 x 30 to give 20 in the 30 row for A). You should create a factor and aggregate in the usual manner.

> aggregate(Combs[ , 3:5], list(Combs$Average), FUN=sum)
   Group.1 counts.x counts.y Average
1     -495        7        0    -495
2     -490        6        0    -490
3     -485        2        0    -485
4     -480        2        0    -480
5     -475        1        0    -475
6     -470        1        0    -470
7       10       21        0      10
8       15       42        1      15
9       20       29        2      40
10      25       26        4      50
11      30       20        9      90
... rest of output deleted.

The top and bottom rows of both tables appear to me to have no value. They are not really items in the sample space or the problem and their purpose remains a mystery.


(And ... Please do learn to include context.)


David Arnold
College of the Redwoods

--

David Winsemius, MD
Alameda, CA, USA

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to