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

Replace delete_columns()? #446

Closed
Tracked by #459
nikosbosse opened this issue Nov 15, 2023 · 2 comments
Closed
Tracked by #459

Replace delete_columns()? #446

nikosbosse opened this issue Nov 15, 2023 · 2 comments
Labels
implementation-ready This is ready for implementation refactor Code refactoring

Comments

@nikosbosse
Copy link
Contributor

In previous versions, data.table errored if you tried to delete a column that didn't exist. We therefore have a function

delete_columns <- function(df, cols_to_delete, make_unique = FALSE) {
  df <- data.table::as.data.table(df)
  delete_columns <- names(df)[names(df) %in% cols_to_delete]
  if (length(delete_columns) > 0) {
    if (make_unique) {
      df <- unique(df[, eval(delete_columns) := NULL])
    } else {
      df <- df[, eval(delete_columns) := NULL]
    }
  }
  return(df)
}

We could alternatively replace this with suppressWarnings(dt[, coltodelete := NULL). Any objections?

@nikosbosse nikosbosse converted this from a draft issue Nov 15, 2023
@nikosbosse
Copy link
Contributor Author

@sbfnk, @sbfnk

@nikosbosse nikosbosse added the refactor Code refactoring label Nov 18, 2023
@nikosbosse nikosbosse changed the title Discussion: replace delete_columns()? Replace delete_columns()? Dec 5, 2023
@nikosbosse nikosbosse added the implementation-ready This is ready for implementation label Dec 5, 2023
@nikosbosse nikosbosse added this to the scoringutils 2.x milestone Dec 5, 2023
nikosbosse added a commit that referenced this issue Dec 14, 2023
Issue #446: Remove function `delete_columns()`
@nikosbosse
Copy link
Contributor Author

Fixed via #529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implementation-ready This is ready for implementation refactor Code refactoring
Projects
Development

No branches or pull requests

1 participant