xtp: Cross tabulation Analysis

Description Usage Arguments Value Examples

View source: R/xtp.r

Description

Generates cross-tabulation of dependent and indendent variables, also creates a mosiac plot. Makes use of the crosstab function in the descr package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
xtp(
  data,
  y,
  x,
  w = NULL,
  ylab = NULL,
  xlab = NULL,
  main = NULL,
  digits = 2,
  chisq = FALSE
)

Arguments

data

Dataset (like gss, nes, states, or world)

y

Dependent variable

x

Independent variable

w

Weights (optional)

ylab

Y-axis label (optional)

xlab

X-axis label (optional)

main

Main label for plot (optional)

digits

Number of digits to report after decimal place, optional (default = 2)

chisq

Do you want Chi-Squared test reported? (default is FALSE)

Value

A data frame of the cross tabulation results

Examples

1
2
3
   library(poliscidata)
   
   xtp(gss, grass, attend3, wtss)

Example output

   Cell Contents 
|-------------------------|
|                   Count | 
|          Column Percent | 
|-------------------------|

=============================================
             attend3
grass          Low   Moderate    High   Total
---------------------------------------------
LEGAL         326        149     100     575 
             62.3%      45.8%   26.7%        
---------------------------------------------
NOT LEGAL     197        176     275     648 
             37.7%      54.2%   73.3%        
---------------------------------------------
Total         523        325     375    1223 
             42.8%      26.6%   30.7%        
=============================================

poliscidata documentation built on July 8, 2020, 6:23 p.m.

Related to xtp in poliscidata...