wtable | R Documentation |

Computes a contingency table from one or two vectors, with the possibility of specifying weights.

wtable(x,y=NULL,weights=rep.int(1,length(x)),stat="freq", digits=1,mar=TRUE,na_value=NULL)

`x` |
an object which can be interpreted as factor |

`y` |
an optional object which can be interpreted as factor |

`weights` |
an optional numeric vector of weights (by default, a vector of 1 for uniform weights) |

`stat` |
character. Whether to compute a contingenct table ("freq", default, percentages ("prop"), row percentages ("rprop") or column percentages ("cprop"). |

`digits` |
integer indicating the number of decimal places (default is 1) |

`mar` |
logical. If TRUE (default), margins are computed |

`na_value` |
character. Name of the level for NA category. If NULL (default), NA values are ignored. |

Returns a contingency table.

Nicolas Robette

`table`

, `assoc.twocat`

## Computes a contingency table ## of jazz and age variables ## from the 'Music' example data set ## with or without weights data(Music) wtable(Music$Jazz) wtable(Music$Jazz,Music$Age) weight <- rep(c(0,0.5,1,1.5,2), length.out=nrow(Music)) wtable(Music$Jazz,w=weight,digits=1) wtable(Music$Jazz,Music$Age,weight,1)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.