mark_duplicates: Mark duplicate IP addresses and/or locations

View source: R/duplicates.R

mark_duplicatesR Documentation

Mark duplicate IP addresses and/or locations

Description

The mark_duplicates() function creates a column labeling rows of data that have the same IP address and/or same latitude and longitude. The function is written to work with data from Qualtrics surveys.

Usage

mark_duplicates(
  x,
  id_col = "ResponseId",
  ip_col = "IPAddress",
  location_col = c("LocationLatitude", "LocationLongitude"),
  rename = TRUE,
  dupl_ip = TRUE,
  dupl_location = TRUE,
  include_na = FALSE,
  quiet = FALSE,
  print = TRUE
)

Arguments

x

Data frame (preferably imported from Qualtrics using {qualtRics}).

id_col

Column name for unique row ID (e.g., participant).

ip_col

Column name for IP addresses.

location_col

Two element vector specifying columns for latitude and longitude (in that order).

rename

Logical indicating whether to rename columns (using rename_columns())

dupl_ip

Logical indicating whether to check IP addresses.

dupl_location

Logical indicating whether to check latitude and longitude.

include_na

Logical indicating whether to include rows with NAs for IP address and location as potentially excluded rows.

quiet

Logical indicating whether to print message to console.

print

Logical indicating whether to print returned tibble to console.

Details

To record this information in your Qualtrics survey, you must ensure that Anonymize responses is disabled.

Default column names are set based on output from the qualtRics::fetch_survey(). By default, IP address and location are both checked, but they can be checked separately with the dupl_ip and dupl_location arguments.

The function outputs to console separate messages about the number of rows with duplicate IP addresses and rows with duplicate locations. These counts are computed independently, so rows may be counted for both types of duplicates.

Value

An object of the same type as x that includes a column marking rows with duplicate IP addresses and/or locations. For a function that just checks for and returns duplicate rows, use check_duplicates(). For a function that excludes these rows, use exclude_duplicates().

See Also

Other duplicates functions: check_duplicates(), exclude_duplicates()

Other mark functions: mark_duration(), mark_ip(), mark_location(), mark_preview(), mark_progress(), mark_resolution()

Examples

# Mark duplicate IP addresses and locations
data(qualtrics_text)
df <- mark_duplicates(qualtrics_text)

# Remove preview data first
df <- qualtrics_text %>%
  exclude_preview() %>%
  mark_duplicates()

# Mark only for duplicate locations
df <- qualtrics_text %>%
  exclude_preview() %>%
  mark_duplicates(dupl_location = FALSE)

excluder documentation built on Feb. 16, 2023, 7:09 p.m.