s-news
[Top] [All Lists]

Re: three questions

To: "jose Bartolomei" <surfprjab@hotmail.com>, "s-plus news" <s-news@lists.biostat.wustl.edu>
Subject: Re: three questions
From: "David Huffer" <David.Huffer@csosa.gov>
Date: Tue, 4 Mar 2008 11:39:47 -0500
Thread-index: Ach+BVm6ijxKzUT9QUmByva+en6oswADObGg
Thread-topic: [S] three questions
On Tuesday, March 04, 2008 9:37, jose Bartolomei wrote:

 > ...It is possible to manipulate or  use  the
 > crosstabs  (ct)  result  values  as separate
 > entities (eg., a<- first row, last  column)?

If by "result values" you mean the counts of each category the
crosstabs function returns an array of counts (among other
things, e.g., attributes containing the marginals) that can be
accessed by index. If all you want is the counts, you can
use table():

   > attach ( solder [ solder $ skips > 10 , ] )
   > xt <- table ( Solder , Opening )
   > detach()
   > xt
          S  M L
    Thin 99 15 9
   Thick 24 11 0
   >

and access "result  values as separate entities" with indices.

For example, here xt is a 2 X 3 matrix and the first row, last
column is:

   > xt [ 1 , 3 ]
   [1] 9
   >

and the entire first row is:

   > xt [ 1 , 1:3 ]
     S  M L
    99 15 9
   >

 > ...Does a weight function to be use with  ct
 > exist?  I  need  to  use   a   vector   that
 > represents a weight for my data....

Are you saying you have frequency weights?  Cant you just multiply
your count matrix by your weights?  Like,

   > uw <- xt / 9
   > uw
             S    M L
    Thin 11.00 1.67 1
   Thick  2.67 1.22 0
   > uw * 9
          S  M L
    Thin 99 15 9
   Thick 24 11 0
   >

or

   > wt <- matrix ( c ( 10 , 20 , 30 , 40 , 50 , 60 ) , nrow = 2 ,
byrow=F)
   > wt
        [,1] [,2] [,3]
   [1,]   10   30   50
   [2,]   20   40   60
   > xt * wt
           S   M   L
    Thin 990 450 450
   Thick 480 440   0
   >

--
David Huffer

<Prev in Thread] Current Thread [Next in Thread>