sjPlot icon indicating copy to clipboard operation
sjPlot copied to clipboard

`view_df()`: Show variables with complete NA's.

Open brianmsm opened this issue 2 years ago • 1 comments

Is there any way or possibility to request that the output also shows variables containing full NA's? I thought that adding show.na = TRUE would do it, but it seems that it is only to add a column to report the presence of missing values.

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(sjPlot)

df <- tibble(
  var1 = c(rep(1, 5), rep(2, 3), rep(3, 10)),
  var2 = c(rep(1, 3), rep(2, 5), rep(3, 8), rep(NA_integer_, 2)),
  var3 = NA_integer_
)

df <- df %>%
  sjlabelled::set_labels(var1, var2, var3,
                         labels = c("Option 1" = 1,
                                    "Option 2" = 2,
                                    "Option 3" = 3))  %>%
  sjlabelled::var_labels(var1 = "Variable 1", 
                         var2 = "Variable 2",
                         var3 = "Variable 3")


sjPlot::view_df(df, show.type = TRUE, show.na = TRUE)
#> Following 1 variables have only missing values and are not shown:
#> var3 [3]
Data frame: df
ID Name Type Label missings Values Value Labels
1 var1 numeric Variable 1 0 (0.00%) 1
2
3
Option 1
Option 2
Option 3
2 var2 numeric Variable 2 2 (11.11%) 1
2
3
Option 1
Option 2
Option 3

Created on 2022-06-04 by the reprex package (v2.0.1)

brianmsm avatar Jun 04 '22 05:06 brianmsm

Currently, this is not possible.

strengejacke avatar Jun 05 '22 07:06 strengejacke