Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I omit the missing value row from table1 in R

I have a dataset as below. When I make a table1 from it using table1(), there is a row given for missing values. I was wondering if it is possible to exclude the 'missing row' from one of the variables (say var3).

The reason I want to do this is because, in my actualy dataset, I have a variable length of hospital stay. Not all the individuals in the dataset are in hospital, so these patients don't have missing data, they just don't have data for this variable as they weren't in the hospital to provide it.

Any help would be appreciated, thanks.

data <- data.frame(
  var1 = c(1, 2, NA, 4, 5),
  var2 = c("A", "B", NA, "D", "E"),
  var3 = c(10, NA, 30, 40, 50)
)

table1(~var1 + var2 + var3, data=data) 
like image 431
Martin Avatar asked Oct 15 '25 11:10

Martin


1 Answers

Use render.missing = NULL (which is not in the help (?table1::table1) for some reason!):

table1::table1(~var1 + var2 + var3, data=data, render.missing = NULL) 

enter image description here

like image 88
jpsmith Avatar answered Oct 17 '25 05:10

jpsmith