You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/04/20 17:19:15 UTC

[GitHub] [arrow] jorisvandenbossche commented on a change in pull request #10056: ARROW-12184: [R] Bindings for na.fail, na.omit, na.exclude, na.pass

jorisvandenbossche commented on a change in pull request #10056:
URL: https://github.com/apache/arrow/pull/10056#discussion_r616888206



##########
File path: r/R/arrow-tabular.R
##########
@@ -211,6 +211,29 @@ head.ArrowTabular <- head.ArrowDatum
 #' @export
 tail.ArrowTabular <- tail.ArrowDatum
 
+#' @export
+na.fail.ArrowTabular <- function(object, ...){
+  na_count <- sum(purrr::map_int(object$columns, ~.x$null_count))
+  if(na_count > 0){
+    stop("missing values in object")
+  }
+  object
+}
+
+#' @export
+na.omit.ArrowTabular <- function(object, ...){
+  filter_text = paste0(
+    ".data$Filter(",
+    paste0("!is.na(.data$", names(object), ")", collapse = " & "),
+    ")"
+  )
+  filter = rlang::parse_expr(filter_text)
+  rlang::eval_tidy(filter,  rlang::new_data_mask(rlang::env(.data = object)))
+}

Review comment:
       This looks much cleaner now!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org