# Generated by 02-duckplyr_df-methods.R
#' @export
rows_update.duckplyr_df <- function(x, y, by = NULL, ..., unmatched = c("error", "ignore"), copy = FALSE, in_place = FALSE) {
# Our implementation
rel_try(NULL,
"No relational implementation for rows_update()" = TRUE,
{
return(out)
}
)
# dplyr forward
rows_update <- dplyr$rows_update.data.frame
out <- rows_update(x, y, by, ..., unmatched = unmatched, copy = copy, in_place = in_place)
return(out)
# dplyr implementation
check_dots_empty()
rows_df_in_place(in_place)
y <- auto_copy(x, y, copy = copy)
by <- rows_check_by(by, y)
rows_check_x_contains_y(x, y)
rows_check_contains_by(x, by, "x")
rows_check_contains_by(y, by, "y")
x_key <- dplyr_col_select(x, by)
y_key <- dplyr_col_select(y, by)
rows_check_unique(y_key, "y")
args <- vec_cast_common(x = x_key, y = y_key)
x_key <- args$x
y_key <- args$y
values_names <- setdiff(names(y), names(y_key))
x_values <- dplyr_col_select(x, values_names)
y_values <- dplyr_col_select(y, values_names)
y_values <- rows_cast_y(y_values, x_values)
keep <- rows_check_y_unmatched(x_key, y_key, unmatched)
if (!is.null(keep)) {
y_key <- dplyr_row_slice(y_key, keep)
y_values <- dplyr_row_slice(y_values, keep)
}
loc <- vec_match(x_key, y_key)
match <- !is.na(loc)
y_loc <- loc[match]
x_loc <- which(match)
y_values <- dplyr_row_slice(y_values, y_loc)
x_values <- vec_assign(x_values, x_loc, y_values)
x_values <- dplyr_new_list(x_values)
x <- dplyr_col_modify(x, x_values)
x
}
duckplyr_rows_update <- function(x, y, ...) {
try_fetch(
{
x <- as_duckplyr_df(x)
y <- as_duckplyr_df(y)
},
error = function(e) {
testthat::skip(conditionMessage(e))
}
)
out <- rows_update(x, y, ...)
class(out) <- setdiff(class(out), "duckplyr_df")
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.