Skip to contents

Download survey data from Forsta and load it in R.

Usage

forsta_get_data(
  survey_id,
  condition = "qualified",
  use_metadata = TRUE,
  label_delim = " | ",
  verbose = FALSE,
  decipher_key = Sys.getenv("DECIPHER_KEY")
)

Arguments

survey_id

Survey ID (e.g., "selfserve/57a/250403").

condition

Character. The condition to use for filtering the data. Available keywords: all, qualified, terminated, overquota, partials, everything. Default is qualified, which means that only qualified responses will be returned.

use_metadata

Logical. If TRUE, function will download metadata and attach it as attribute. Function will also fix broken labels and levels due to character limitations in SPSS format (255 char/120 char).

label_delim

Character. The delimiter to use for the labels. Default is " | ".

verbose

Logical. If TRUE, the function will print information about fixing labels and levels.

decipher_key

Character. The API key for Forsta. If not provided, it will look for the DECIPHER_KEY environment variable.

Examples

if (FALSE) { # \dontrun{
srv_data <- forsta_get_data("selfserve/57a/250404")

# Check updated label
attr(srv_data, "metadata") |> select(label)

# Check updated levels
attr(srv_data, "metadata") |> select(levels)

# Turn on console output
forsta_get_data("selfserve/57a/250404", verbose = TRUE)
} # }