Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove_empty: select empty columns #530

Open
luizaandrade opened this issue Feb 8, 2023 · 2 comments
Open

remove_empty: select empty columns #530

luizaandrade opened this issue Feb 8, 2023 · 2 comments
Labels
seeking comments Users and any interested parties should please weigh in - this is in a discussion phase!

Comments

@luizaandrade
Copy link

I have come across a number of cases where I'd like to remove rows (column) that are empty for some selected columns (rows), but not all. The most straightforward example is that of a data table that has non-empty keys in all rows, but some rows have no information in the other columns. Like this:

key var1 var2 var3
1 10 "foo" TRUE
2 NA NA NA
3 32 "bar" TRUE

Although the second row is not completely empty, it would be useful to be able to remove it quickly and neatly.

@sfirke
Copy link
Owner

sfirke commented Feb 8, 2023

Would the ideal implementation of this be a tidyselect ... for the remove_empty function, so that you could say remove_empty(dat,,,,-key) ? That seems like a worthwhile addition to me, with little downside.

In the meantime would this work?

dat <- data.frame(
  key = 1:3,
  var1 = c(10, NA, 32),
  var2 = c("foo", NA, "bar"),
  var3 = c(TRUE, NA, FALSE)
)

dat %>%
  remove_empty("rows", cutoff = 0.7)

@sfirke sfirke added the seeking comments Users and any interested parties should please weigh in - this is in a discussion phase! label Feb 8, 2023
@luizaandrade
Copy link
Author

Great! Yes, the tidyselect is exactly what I had in mind.
And thanks, the cutoff options does the trick for now and is a very nice feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
seeking comments Users and any interested parties should please weigh in - this is in a discussion phase!
Projects
None yet
Development

No branches or pull requests

2 participants