ar_normalize
performs normalization steps for responses (and cues) and wraps around ar_normalize_manual.
Usage
ar_normalize(
associations,
case = "most_frequent",
punct = "end",
punct_replacement = " ",
whitespace = "squish",
process_cues = TRUE
)
Arguments
- associations
an
associatoR
object containing association data as generated by ar_import.- case
a
character
specifying the normalization of cases orNULL
to not change casing. Must be one ofc("lower", "upper", "sentence", "most_frequent")
orNULL
. Settingcase = "lower"
normalizes all responses to lower case,case = "lower"
to upper case,case = "sentence"
to sentence case, andcase = "most_frequent"
to the most frequent casing for each string.- punct
a
character
specifying the normalization of punctuationorNULL
to not change punctuation. Must be one ofc("end", "all")
orNULL
.punct = "end"
replaces all punctuation at the end (including following whitespaces) withpunct_replacement
(default is a single white space).punct = "all"
replaces all punctuation.- punct_replacement
a
character
used as replacement for punctuation.- whitespace
a
character
specifying the normalization of white spaces orNULL
to not change whitespace. Must be one ofc("squish", "trim")
orNULL
. Settingwhitespace = "squish"
removes additional white spaces at the start, the end, and in-between words, whereas settingwhitespace = "trim"
removes white space from the start and end.- process_cues
a
logical
specifying, if cues should be processed as well. Defaults toTRUE
.
Value
Returns an associatoR
object containing a list of tibbles:
- participants
A tibble of participants including a participant
id
and potential participant attributes.- cues
A tibble of cues including a
cue
variable and potential cue attributes.- responses
A tibble of responses including a participant id, the cues, the responses, the response level, and additional response attributes.
Examples
ar_import(intelligence,
participant = participant_id,
cue = cue,
response = response,
participant_vars = c(gender, education),
response_vars = c(response_position, response_level)) %>%
ar_normalize(case = "lower", punct = "all")
#> 197 entries were dropped from cues due to normalizing.
#>
#> ── An associatoR object ────────────────────────────────────────────────────────
#>
#> participants
#> # A tibble: 1,000 × 3
#> id gender education
#> <dbl> <chr> <chr>
#> 1 1 male high school
#> 2 2 male high school
#> 3 3 male high school
#> 4 4 male high school
#> 5 5 male high school
#> # ℹ 995 more rows
#>
#> cues
#> # A tibble: 607 × 2
#> cue cue_original
#> <chr> <chr>
#> 1 intelligence intelligence
#> 2 einstein Einstein
#> 3 books books
#> 4 iq tests IQ tests
#> 5 college college
#> # ℹ 602 more rows
#>
#> responses
#> # A tibble: 29,882 × 7
#> id cue response response_position response_level cue_original
#> <dbl> <chr> <chr> <dbl> <dbl> <chr>
#> 1 1 intelligence einstein 1 1 intelligence
#> 2 1 intelligence books 2 1 intelligence
#> 3 1 intelligence iq tests 3 1 intelligence
#> 4 1 intelligence college 4 1 intelligence
#> 5 1 intelligence smart people 5 1 intelligence
#> # ℹ 29,877 more rows
#> # ℹ 1 more variable: response_original <chr>
#>