Hi!

Is it possible to automatically construct a table like this:

#                        treat B
#                       improvement
#                         +       -
#treat A improvement  +   1       3
#                     -   2       1

 From these data:

pair  <- c(1,1,2,2,3,3,4,4,5,5,6,6,7,7)  # identification
treat <- c(1,0,1,0,1,0,1,0,1,0,1,0,1,0) # treatament 1 (A) or 0 (B)
impr  <- c(1,0,1,0,1,0,0,1,0,1,0,0,1,1) # improvement 1 (yes) 0 (no)

treatfac <- factor(treat)
levels(treatfac)<-list("A"=1,"B"=0 )
imprfac <- factor(impr)
levels(imprfac)<-list("+"=1,"-"=0)

data.frame(pair,treatfac,imprfac)

    pair treatfac imprfac

1     1      A     +
2     1      B     -
3     2      A     +
4     2      B     -
5     3      A     +
6     3      B     -
7     4      A     -
8     4      B     +
9     5      A     -
10    5      B     +
11    6      A     -
12    6      B     -
13    7      A     +
14    7      B     +

I tried some functions like table or even xtabs, but the results doesn't 
show the pairs combinations.


Thanks in advance,


MaurĂ­cio Cardeal

Federal University of Bahia, Brazil




        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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