I tried to use remove_empty() from {janitor} to remove all the NA-only columns/rows, but I could only remove the NA-only column, leaving the NA-only row
data <- data.frame(x1 = c(1:4, 99999, 1, NA, 1, 1, NA), # Create example data frame
> x1 = c(1:5, 1, "NA", 1, 1, "NA"),
> x1 = c(letters[c(1:3)], "x x", "x", "y y y", "x", "a", "a", NA),
> x4 = "",
> x5 = NA)
>
> data_y <- replace(data, data=='', NA)
> data_y <- data %>% remove_empty(which = c("rows","cols"))
What I got:
x1 x1.1 x1.2 x4
> 1 1 1 a
> 2 2 2 b
> 3 3 3 c
> 4 4 4 x x
> 5 99999 5 x
> 6 1 1 y y y
> 7 NA NA x
> 8 1 1 a
> 9 1 1 a
> 10 NA NA < NA >
Row #10 was still there, and somehow the column name of "x4" was there too.
Is there anything wrong with my code?