Re: [R] Reading contingency tables

From: Giovanni Petris <GPetris_at_uark.edu>
Date: Fri 19 Jan 2007 - 16:20:34 GMT

> Date: Fri, 19 Jan 2007 11:08:22 -0500
> From: Gabor Grothendieck <ggrothendieck@gmail.com>
> Cc: ripley@stats.ox.ac.uk, r-help@stat.math.ethz.ch
> DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta;
>
> You are writing out x rather than ft. If you do:
>
> write.ftable(ft, file = stdout())
>
> it looks the same as the input.
>

You are wright. The point I was trying to make is that read.ftable does not work as (I) expected for an ftable with two column variables.

Giovanni

>
> On 1/19/07, Giovanni Petris <GPetris@uark.edu> wrote:
> >
> > Thank you, Prof Ripley.
> >
> > However, there is still something unclear to me about read.ftable. I
> > noticed the following behavior, which I found strange. I expected
> > read.ftable to be an "inverse" of write.ftable, so to speak. Is there
> > something I am missing, or is this a problem in read.ftable?
> >
> > Thanks,
> > Giovanni
> >
> > > file <- tempfile()
> > > cat(" Intercourse\n",
> > + "Race Gender Yes No\n",
> > + "White Male 43 134\n",
> > + " Female 26 149\n",
> > + "Black Male 29 23\n",
> > + " Female 22 36\n",
> > + file = file)
> > > file.show(file)
> > Intercourse
> > Race Gender Yes No
> > White Male 43 134
> > Female 26 149
> > Black Male 29 23
> > Female 22 36
> >
> > > ft <- read.ftable(file)
> > > ft ## OK so far
> > Intercourse Yes No
> > Race Gender
> > White Male 43 134
> > Female 26 149
> > Black Male 29 23
> > Female 22 36
> > > x <- as.table(ft)
> > > write.ftable(ftable(x, col.vars=2:3), file)
> > > file.show(file)
> > "Gender" "Male" "Female"
> > "Intercourse" "Yes" "No" "Yes" "No"
> > "Race"
> > "White" 43 134 26 149
> > "Black" 29 23 22 36
> >
> > > ft2 <- read.ftable(file)
> > > ft2
> > Gender Male Female
> > Intercourse Yes No Yes No Yes No Yes No
> > Race
> > White 43 134 26 149 29 23 22 36
> > Black 43 134 26 149 29 23 22 36
> > > version
> > _
> > platform sparc-sun-solaris2.8
> > arch sparc
> > os solaris2.8
> > system sparc, solaris2.8
> > status
> > major 2
> > minor 4.1
> > year 2006
> > month 12
> > day 18
> > svn rev 40228
> > language R
> > version.string R version 2.4.1 (2006-12-18)
> >
> > --
> >
> > Giovanni Petris <GPetris@uark.edu>
> > Associate Professor
> > Department of Mathematical Sciences
> > University of Arkansas - Fayetteville, AR 72701
> > Ph: (479) 575-6324, 575-8630 (fax)
> > http://definetti.uark.edu/~gpetris/
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch 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.
> >
>



R-help@stat.math.ethz.ch 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 Sat Jan 20 03:37:56 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 19 Jan 2007 - 17:30:27 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.