I am trying to create a table (for chi-square test) that presents "unadjstatus" and "status" values like so
unadjstatus status
low 4 5
ok 2 1
using the data below
data.frame(stringsAsFactors=FALSE,
unadjstatus = c("low", "low", "low", "low", "ok", "ok"),
inf1 = c("norm", "inflammed", "norm", "inflammed", "inflammed",
"norm"),
status = c("low", "low", "low", "low", "ok", "low"),
I have tried most of the basic functions such as
x=count(men,c("status","unadjstatus"))
Error: Column `c("status", "unadjstatus")` must be length 215 (the number of rows) or one, not 2
> x
status unadjstatus freq
1 low low 5
2 ok low 2
3 ok ok 0
> apply(men[cols],count)
Error in match.fun(FUN) : argument "FUN" is missing, with no default
> apply(men[cols],2,count)
$status
x freq
1 low 5
2 ok 1
$unadjstatus
x freq
1 low 4
2 ok 2
I am obviously missing something because it's either presenting the frequency separately, or counting them together. Any suggestions on a function that could work? I also tried ddply() and cbind() but kept getting similar results