[R] reading contigency tables

Johannes Hüsing johannes at huesing.name
Wed Jan 11 08:42:20 CET 2006


Just a remark:

> I need some help using read.ftable to read a contingency table. My columns
> are organized as follows:
> order--family--species--location--number of individuals

As the first three variables are nested, I would expect this table
to contain a lot of structural zeroes. I understand you just get
the data in table form and do not intend to work on them as a
contingency table.

> I couldn't figure out how to change the data on my text file to be
> imported into R; and after you do that, is it possible to convert the
> table into a data frame? Any tips would be greatly appreciatted!

data(HairEyeColor)
condensed <- as.data.frame(HairEyeColor)

If this is not sufficient, then

extended <- condensed[-ncol(condensed),
                      rep(1:nrow(condensed),
                          condensed[,ncol(condensed)])]

should do the trick.

Greetings


Johannes




More information about the R-help mailing list