s-news
[Top] [All Lists]

simple table question

To: s-news@lists.biostat.wustl.edu
Subject: simple table question
From: "Colin Maurice" <colinsplus@hotmail.com>
Date: Fri, 17 Feb 2006 10:13:15 -0500

Hello members,

I have a simple tabluation question that has been bugging me for a bit. I would appreciate any assistance with it.

Suppose I have the following data.frame

x
     X1       X2 X3    X4
1 name1 Letter A  1 cat a
2 name1 Letter B  2   cat
3 name1 Letter A  3    bb
4 name1 Letter B  1    re
5 name1 Letter A  2 cat a
6 name2 Letter B  3   cat
7 name2 Letter A  1    bb
8 name2 Letter B  2    re
9 name2 Letter A  3 cat a
10 name2 Letter B  1   cat

I would like a tabulation for each category in X1 when X2 contains the letter "A", and X4 has occurrence "cat a"


my.names <- unique(x$X1)
my.names2 <- factor(x$X1, my.names)
table(my.names2, regMatch(x$X4, "cat a") & regMatch(x$X2, "A"))

    FALSE TRUE
name1     3    2
name2     4    1

I'm only after the true occurences not the false column. How do I put this conidtion into the table command without using the "[,2]" at the end of the command.

Thank you for any help.

Colin

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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