I'm using xtabs
to tabulate some data that contains NA
s. In order to make sure the totals are complete, I'm using addNA
to count the ones with missing factor levels.
However, this causes problems when using xtable
to export to LaTeX for Sweaving because there are NA
s in the row and column names now. I have a solution:
rownames(tab)[is.na(rownames(tab))]<-"NA"
colnames(tab)[is.na(colnames(tab))]<-"NA"
But this can become tiresome for lots of tables, is there a way of doing this more automatically? Or is there a better way of producing the tables in the first place?