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.

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

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
  )
#> # A tibble: 200 × 9
#>    trt      age marker stage grade response death ttdeath    id
#>    <chr>  <dbl>  <dbl> <fct> <fct>    <int> <int>   <dbl> <int>
#>  1 Drug A    56  0.16  T1    II           0     0    24       1
#>  2 Drug C     9  1.11  T2    I            1     0    24       2
#>  3 Drug A    31  0.277 T1    II           0     0    24       3
#>  4 Drug A    NA  2.07  T3    III          1     1    17.6     4
#>  5 Drug A    51  2.77  T4    III          1     1    16.4     5
#>  6 Drug B    39  0.613 T4    I            0     1    15.6     6
#>  7 Drug A    37  0.354 T1    II           0     0    24       7
#>  8 Drug A    32  1.74  T1    I            0     1    18.4     8
#>  9 Drug A    31  0.144 T1    II           0     0    24       9
#> 10 Drug B    34  0.205 T3    I            0     1    10.5    10
#> # … with 190 more rows