I'm trying to create a set of crosstabs in R using the tab_cells
command in the expss
package that shows me counts, the total, and my NAs. I can't get it to give me NAs.
I've tried using na_if
and tab_mis_val
and I've tried doing it using the cro command. I've found a frequency table that I really like using fre and I want to replicate it basically as a crosstab. I've also used tabyl
from the janitor
package and can get the NA row but I can only run one crosstab at a time instead of saying from var1 to var10.
#I feel like I'm close with this
data%>%
tab_cells(var1 %to% var10) %>%
tab_cols(total(), var12) %>%
tab_stat_cpct() %>%
tab_mis_val() %>%
tab_pivot()
#frequency table I really like that DOES give me NAs
expss_output_viewer()
calculate(data, fre(as.list(var1 %to% var10)))
#attempt to make it as a crosstab
expss_output_viewer()
calculate(data, cro_cases(as.list(var1 %to% var10, var12)))
#Using tabyl I can get NAs but it will only give one one crosstab at a
# time instead of a` whole set of them.
library(janitor)
data %>%
tabyl(var1, var12) %>%
adorn_totals(c("row", "col")) %>%
adorn_percentages("row") %>%
adorn_pct_formatting() %>%
adorn_ns() %>%
adorn_title("combined") %>%
knitr::kable()
I want a table with counts, percents, a total row, and an NA row. I cannot seem to get the NA row with tab_cells
.