R provides many methods for creating frequency and contingency tables. For example, let’s assume we have a 3-way contingency table based on variables A, B, and C. To get a 2-way frequency table (i.e. a frequency table of the counts of a data set as divided by 2 categorical variables), you can display it in a cross-tabulated format or in a list format. I have a three level contingency table, with count data for several species, the host plant from which they were collected and whether that collection happened on a rainy day (this actually matters.
Here we look at some examples of how to work with two way tables. We begin with the structure of a three-way table, and its corresponding joint, marginal and conditional distributions. A two-way table is a table that describes two categorical data variables together, and R gives you a whole toolset to work with two-way tables.
Introduction One feature that I like about R is the ability to access and manipulate the outputs of many functions. Let us read the data into R: femsmoke – read.table(femsmoke.txt) femsmoke. y smoker dead age. 1 2 yes yes 18-24. 2 1 no yes 18-24. 3 3 yes yes 25-34.