check_duplicates {excluder} | R Documentation |
Check for duplicate IP addresses and/or locations
Description
The check_duplicates()
function subsets rows of data, retaining rows
that have the same IP address and/or same latitude and longitude. The
function is written to work with data from
Qualtrics surveys.
Usage
check_duplicates(
x,
id_col = "ResponseId",
ip_col = "IPAddress",
location_col = c("LocationLatitude", "LocationLongitude"),
rename = TRUE,
dupl_ip = TRUE,
dupl_location = TRUE,
include_na = FALSE,
keep = 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 |
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. |
keep |
Logical indicating whether to keep or remove exclusion column. |
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 the rows with
duplicate IP addresses and/or locations. This includes a column
called dupe_count that returns the number of duplicates.
For a function that marks these rows, use mark_duplicates()
.
For a function that excludes these rows, use exclude_duplicates()
.
See Also
Other duplicates functions:
exclude_duplicates()
,
mark_duplicates()
Other check functions:
check_duration()
,
check_ip()
,
check_location()
,
check_preview()
,
check_progress()
,
check_resolution()
Examples
# Check for duplicate IP addresses and locations
data(qualtrics_text)
check_duplicates(qualtrics_text)
# Check only for duplicate locations
qualtrics_text %>%
check_duplicates(dupl_location = FALSE)
# Do not print rows to console
qualtrics_text %>%
check_duplicates(print = FALSE)
# Do not print message to console
qualtrics_text %>%
check_duplicates(quiet = TRUE)