Learn R Programming

tidydp (version 0.1.0)

dp_count: Differentially Private Count

Description

Computes a differentially private count of rows, optionally grouped by specified columns.

Usage

dp_count(data, epsilon, delta = NULL, group_by = NULL, .budget = NULL)

Value

Data frame with (possibly grouped) counts

Arguments

data

A data frame

epsilon

Privacy parameter

delta

Privacy parameter (default: NULL, uses Laplace mechanism)

group_by

Character vector of column names to group by (optional)

.budget

Optional privacy budget object to track expenditure

Examples

Run this code
data <- data.frame(city = c("NYC", "LA", "NYC", "LA", "NYC"),
                   age = c(25, 30, 35, 40, 45))
# Overall count
dp_count(data, epsilon = 0.1)

# Grouped count
data %>% dp_count(epsilon = 0.1, group_by = "city")

Run the code above in your browser using DataLab