check_location {excluder}R Documentation

Check for locations outside of the US

Description

The check_location() function subsets rows of data, retaining rows that have locations outside of the US. The function is written to work with data from Qualtrics surveys.

Usage

check_location(
  x,
  id_col = "ResponseId",
  location_col = c("LocationLatitude", "LocationLongitude"),
  rename = 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).

location_col

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

rename

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

include_na

Logical indicating whether to include rows with NA in latitude and longitude columns in the output list of potentially excluded data.

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(). The function only works for the United States. It uses the #' maps::map.where() to determine if latitude and longitude are inside the US.

The function outputs to console a message about the number of rows with locations outside of the US.

Value

The output is a data frame of the rows that are located outside of the US and (if include_na == FALSE) rows with no location information. For a function that marks these rows, use mark_location(). For a function that excludes these rows, use exclude_location().

See Also

Other location functions: exclude_location(), mark_location()

Other check functions: check_duplicates(), check_duration(), check_ip(), check_preview(), check_progress(), check_resolution()

Examples

# Check for locations outside of the US
data(qualtrics_text)
check_location(qualtrics_text)

# Remove preview data first
qualtrics_text %>%
  exclude_preview() %>%
  check_location()

# Do not print rows to console
qualtrics_text %>%
  exclude_preview() %>%
  check_location(print = FALSE)

# Do not print message to console
qualtrics_text %>%
  exclude_preview() %>%
  check_location(quiet = TRUE)

[Package excluder version 0.5.1 Index]