[R] newbie subset question

From: Farley, Robert <FarleyR_at_metro.net>
Date: Thu, 03 Apr 2008 16:27:45 -0700


I want to look at all the records making up a "row and column" of a crosstab, but I'm not getting it right. I'm trying to use subset() but my selection ((prod_act=="other") || (attr_act=="other")) gives my no records. See the second table below. Getting just the row does work, as seen in the third table.  

Why is this failing me?    

> .Table <- xtabs(~prod_act+attr_act, data=Dataset) ; .Table ;
remove(.Table)

            attr_act

prod_act dk/rf home other school shop soc/rec university work

  dk/rf 52 0 0 0 0 0 0 0

  home 0 12380 2826 552 1204 1054 2709 15842

  other 0 0 703 1 62 48 42 227

  school 0 0 7 187 4 11 0 8

  shop 0 0 29 1 466 17 7 30

  soc/rec 0 0 39 1 22 191 8 40

  university 0 0 67 0 40 38 247 119

  work 0 0 215 4 95 76 107 1581

> D2 <- subset(Dataset, ((prod_act=="other") || (attr_act=="other")) ,
select=direction:attr_mta_taz )

> .Table <- xtabs(~prod_act+attr_act, data=D2) ; .Table ;
remove(.Table)

            attr_act

prod_act dk/rf home other school shop soc/rec university work

  dk/rf 0 0 0 0 0 0 0 0

  home 0 0 0 0 0 0 0 0

  other 0 0 0 0 0 0 0 0

  school 0 0 0 0 0 0 0 0

  shop 0 0 0 0 0 0 0 0

  soc/rec 0 0 0 0 0 0 0 0

  university 0 0 0 0 0 0 0 0

  work 0 0 0 0 0 0 0 0

> D3 <- subset(Dataset, (prod_act=="other") ,
select=direction:attr_mta_taz )

> .Table <- xtabs(~prod_act+attr_act, data=D3) ; .Table ;
remove(.Table)

            attr_act

prod_act dk/rf home other school shop soc/rec university work

  dk/rf 0 0 0 0 0 0 0 0

  home 0 0 0 0 0 0 0 0

  other 0 0 703 1 62 48 42 227

  school 0 0 0 0 0 0 0 0

  shop 0 0 0 0 0 0 0 0

  soc/rec 0 0 0 0 0 0 0 0

  university 0 0 0 0 0 0 0 0

  work 0 0 0 0 0 0 0 0

>
   

Robert Farley

Metro

1 Gateway Plaza

Mail Stop 99-23-7

Los Angeles, CA 90012-2952

Voice: (213)922-2532

Fax: (213)922-2868

www.Metro.net    

        [[alternative HTML version deleted]]



R-help_at_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. Received on Thu 03 Apr 2008 - 23:32:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Apr 2008 - 01:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive