library(dplyr) gss = read.csv(file.choose(), header=T) # "GSS3.csv" str(gss) # structure gss = gss[(gss$happy!="Don't know") & (gss$happy!="No answer"),] gss = gss[(gss$jobsecok!="Dont know") & (gss$jobsecok!="No answer") & (gss$jobsecok!="Not applicable"),] tbl = table(gss$jobsecok, gss$happy) library(DescTools) GoodmanKruskalGamma(x,y) # if above individual vectors GoodmanKruskalGamma(tbl, conf.level=.95) # easier KendallTauB(tbl, conf.level=.95) ConDisPairs(tbl) source(file.choose()) # choose MantelHaenszel.R # two-way table of jobsecok (rows) and happy (columns) tbl = matrix(c(15,21,64,73,25,47,248,474,5,21,100,311),nrow=4) # user input scores u and v -- need to match the dimensions of tbl u = c(1,2,3,4); v = c(1,2,3) MH.test(tbl, u, v) # no user input scores, uses midranks MH.test.mid(tbl)