Learn R Programming

baizer (version 0.8.0)

rewrite_na: rewrite the NA values in a tibble by another tibble

Description

rewrite the NA values in a tibble by another tibble

Usage

rewrite_na(x, y, by)

Value

tibble

Arguments

x

raw tibble

y

replace reference tibble

by

columns to align the tibbles

Examples

Run this code

tb1 <- tibble::tibble(
  id = c("id-1", "id-2", "id-3", "id-4"),
  group = c("a", "b", "a", "b"),
  price = c(0, -200, 3000, NA),
  type = c("large", "none", "small", "none")
)

tb2 <- tibble::tibble(
  id = c("id-1", "id-2", "id-3", "id-4"),
  group = c("a", "b", "a", "b"),
  price = c(1, 2, 3, 4),
  type = c("l", "x", "x", "m")
)

rewrite_na(tb1, tb2, by = c("id", "group"))

Run the code above in your browser using DataLab