how to show all the values in table function?

I have a data set of two columns where each variable is expressed as binary variable of 0 or 1.
Here is the screenshot of the data set.

Screen Shot 2020-07-27 at 11.45.18 PM

However, the first column has 0 or 1 for each observation and the model predicted second column has only 0 in this case. When I look at the table for this two columns, then I have something like this.

Screen Shot 2020-07-27 at 11.50.16 PM

I wonder, is there any way that I can show 1 in the column of 2*2 table even though I do not have any 1 in the second column?

Thank you for your help!

Hello, welcome back.

# example
df <- data.frame(
  a = rep(c(0,1),10),
  b = rep(0,20)
)

# recreate issue
table(df$a,df$b)

# possible solution
table(df$a,factor(df$b,levels=c(0,1)))
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.