redact_columns {dittodb}R Documentation

Redact columns from a dataframe with the default redactors


This function redacts the columns specified in columns in the data given in data using dittodb's standard redactors.


redact_columns(data, columns, = TRUE, ...)



a dataframe to redact


character, the columns to redact

should case be ignored? (default: TRUE)


additional options to pass on to grep() when matching the column names


The column names given in the columns argument are treated as regular expressions, however they always have ^ and $ added to the beginning and end of the strings. So if you would like to match any column that starts with the string sensitive (e.g. sensitive_name, sensitive_date) you could use ⁠"sensitive.*⁠ and this would catch all of those columns (though it would not catch a column called most_sensitive_name).

The standard redactors replace all values in the column with the following values based on the columns type:


data, with the columns specified in columns duly redacted


if (check_for_pkg("nycflights13", message)) {
  small_flights <- head(nycflights13::flights)

  # with no columns specified, redacting does nothing
  redact_columns(small_flights, columns = NULL)

  # integer
  redact_columns(small_flights, columns = c("arr_time"))

  # numeric
  redact_columns(small_flights, columns = c("arr_delay"))

  # characters
  redact_columns(small_flights, columns = c("origin", "dest"))

  # datetiems
  redact_columns(small_flights, columns = c("time_hour"))

[Package dittodb version 0.1.4 Index]