fix_database_error: Function to make database fixes after import

Description Usage Arguments Value Examples

View source: R/fix_database_error.R

Description

Use this function to make updates to your data while avoiding adding PHI, such as MRNs, to your code and subsequently PHI in GitHub. You provide a file of database fixes that is three columns: 1. An expression that selects a line in the database to update (e.g. MRN == "12345678"), 2. The column name that will be updated, and 3. The updated value. See the examples for the structure of the database fix input.

Usage

1
fix_database_error(data, engine = readr::read_csv, ...)

Arguments

data

data frame with errors

engine

function to import file of database fixes

...

arguments passed to the engine function to import the database fixes

Value

updated data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
df_fixes <-
  tibble::tribble(
    ~id, ~variable, ~value,
    "id == 1", "age", "56",
    "id == 2", "trt", "Drug C"
  )
trial %>%
  dplyr::mutate(id = dplyr::row_number()) %>%
  fix_database_error(
    engine = I,
    x = df_fixes
  )

ddsjoberg/bstfun documentation built on May 4, 2021, 9:39 a.m.