qualtRics (version 3.1.3)

read_survey: Read a CSV file exported from Qualtrics

Description

Reads comma separated CSV files generated by Qualtrics software. The second line containing the variable labels is imported. Repetitive introductions to matrix questions are automatically removed. Variable labels are stored as attributes.

Usage

read_survey(
  file_name,
  strip_html = TRUE,
  import_id = FALSE,
  time_zone = NULL,
  legacy = FALSE,
  col_types = NULL
)

Arguments

file_name

String. A CSV data file.

strip_html

Logical. If TRUE, then remove HTML tags. Defaults to TRUE.

import_id

Logical. If TRUE, use Qualtrics import IDs instead of question IDs as column names. Defaults to FALSE.

time_zone

String. A local timezone to determine response date values. Defaults to NULL which corresponds to UTC time. See https://api.qualtrics.com/docs/time-zones for more information on format.

legacy

Logical. If TRUE, then import "legacy" format CSV files (as of 2017). Defaults to FALSE.

col_types

Optional. This argument provides a way to manually overwrite column types that may be incorrectly guessed. Takes a cols specification. See example below and cols for formatting details. Defaults to NULL.

Value

A data frame. Variable labels are stored as attributes. They are not printed on the console but are visibile in the RStudio viewer.

Examples

Run this code
# NOT RUN {
# Generic use of read_survey()
df <- read_survey("<YOUR-PATH-TO-CSV-FILE>")
# }
# NOT RUN {
# Example using current data format
file <- system.file("extdata", "sample.csv", package = "qualtRics")
df <- read_survey(file)

# Example using legacy data format
file <- system.file("extdata", "sample_legacy.csv", package = "qualtRics")
df <- read_survey(file, legacy = TRUE)

# Example changing column type
file <- system.file("extdata", "sample.csv", package = "qualtRics")
# Force EndDate to be a string
df <- read_survey(file, col_types = readr::cols(EndDate = readr::col_character()))

# }

Run the code above in your browser using DataCamp Workspace