The problem is that "FN" isn't listed in your input data. You can get around this by calling levels()
and informing R that it is one of your levels, it just is a level that does not have any observations in your dataset. For example,
dframe <- read.table(text=" T1 T2
NN NF
FF FF
NF FF
NN NN
NN FF
NF NF
NF NF
FF FF", header=T)
levels(dframe$T1) <- c("FF", "NF", "NN", "FN")
levels(dframe$T2) <- c("FF", "NF", "NN", "FN")
with(dframe, table(T1,T2))
T2
T1 FF NF NN FN
FF 2 0 0 0
NF 1 2 0 0
NN 1 1 1 0
FN 0 0 0 0
One special note: you are overwriting the original levels here, so you need to put the new, nonexistent, level last, otherwise R will call your "NF" level "FN" and lead to all sorts of problems.