background preloader

R cross tabulation

Facebook Twitter

EnQuireR, Exploration of Questionnaires; automatic reporting for categorical variables analysis (pdf and beamer type) Www.datavis.ca/courses/VCD/vcd-tutorial.pdf. CrossTable {gmodels. Cross Tabulation with Tests for Factor Independence Description An implementation of a cross-tabulation function with output similar to S-Plus crosstabs() and SAS Proc Freq (or SPSS format) with Chi-square, Fisher and McNemar tests of the independence of all table factors.

Usage CrossTable(x, y, digits=3, max.width = 5, expected=FALSE, prop.r=TRUE, prop.c=TRUE, prop.t=TRUE, prop.chisq=TRUE, chisq = FALSE, fisher=FALSE, mcnemar=FALSE, resid=FALSE, sresid=FALSE, asresid=FALSE, missing.include=FALSE, format=c("SAS","SPSS"), dnn = NULL, ...) Arguments x A vector or a matrix. Y A vector in a matrix or a dataframe digits Number of digits after the decimal point for cell proportions max.width In the case of a 1 x n table, the default will be to print the output horizontally. Expected If TRUE, chisq will be set to TRUE and expected cell counts from the Chi-Square will be included prop.r If TRUE, row proportions will be included prop.c If TRUE, column proportions will be included prop.t prop.chisq chisq fisher resid. R CrossTab, gmodels package - InterSciWiki. A better crosstab GRAPHIC HexBin working example‎ R CrossTable() function, gmodels package on CRAN --- Gmodels manual for Gmodels in pdf print pages 2-4 sccs<-read.dta("SCCSvar1-2008NoMapStata8.dta") attach(sccs) library(gmodels) CrossTable(v891,v893,expected=TRUE,prop.chisq=TRUE,fisher=TRUE,dnn=c("v891 Int War","v893 External War:Attacked")) #delete these options if you dont want them #Right click and save to your R working directory then repeat the command above sccs<-read.dta("SCCSvar1-2008NoMapStata8.dta") attach(sccs) names(sccs) length(sccs) #number of variables help(CrossTable) # to see how it works -- help is available on most routines SUCCESS!!!

A289 required readings and exercises Output for the Example For a cleaner table try or Conversion with SPSS 15 From SPSS to R. Frequencies. This section describes the creation of frequency and contingency tables from categorical variables, along with tests of independence, measures of association, and methods for graphically displaying results. Generating Frequency Tables R provides many methods for creating frequency and contingency tables.

Three are described below. In the following examples, assume that A, B, and C represent categorical variables. table You can generate frequency tables using the table( ) function, tables of proportions using the prop.table( ) function, and marginal frequencies using margin.table( ). # 2-Way Frequency Table attach(mydata) mytable <- table(A,B) # A will be rows, B will be columns mytable # print table margin.table(mytable, 1) # A frequencies (summed over B) margin.table(mytable, 2) # B frequencies (summed over A) prop.table(mytable) # cell percentages prop.table(mytable, 1) # row percentages prop.table(mytable, 2) # column percentages Table ignores missing values. Xtabs Crosstable. R - Analysis of multiple response. R Graphical Manual.