According to the tabyl documentation:
However, I can't figure out how to suppress the NA from the denominator!
Please see here for the data:
df <- data.frame(col1 = c(1,1,2,2,1, NA,NA),
col2 = c("this", NA,"is", "text",NA,NA,'yes'),
col3 = c('TRUE', 'FALSE', NA, 'TRUE','TRUE', 'TRUE', 'FALSE'),
col4 = c(2.5, 4.2, 3.2, NA, 4.2, 3.2,3)) %>%
mutate_if(is.numeric, as.factor) %>%
mutate_if(is.character, as.factor)
str(df)
df %>%
tabyl(col1, col3, show_missing_levels = F) %>%
adorn_percentages("row")%>%
adorn_pct_formatting(digits = 2) %>%
adorn_ns()
Note how the percent of the NA is still showing up in the denominator. I don't want to see the NA % at all in the cross tab:
col1 FALSE TRUE NA_
1 33.33% (1) 66.67% (2) 0.00% (0)
2 0.00% (0) 50.00% (1) 50.00% (1)
<NA> 50.00% (1) 50.00% (1) 0.00% (0)
What I want to see:
col1 FALSE TRUE
1 33.33% (1) 66.67% (2)
2 0.00% (0) 100.00% (1)
Any idea how I can achieve this?