Skip to contents

Calculate mean scores on circumplex scales from item responses by using a set of scoring instructions, which may be loaded from the package or created as a custom data frame.

Usage

score(.data, items, instrument, na.rm = TRUE, prefix = "", suffix = "")

Arguments

.data

Required. A data frame containing at least circumplex scales.

items

Required. The variable names or column numbers for the variables in .data that contain all the circumplex items from a single circumplex measure, in ascending order from item 1 to item N.

instrument

Required. An instrument object from the package. To see the available circumplex instruments, use instruments().

na.rm

Optional. A logical that determines if missing values should be omitted from the calculation of scores (default = TRUE). When set to TRUE, scales with missing data are essentially calculated with mean imputation.

prefix

Optional. A string to include at the beginning of the newly calculated scale variables' names, before Abbrev from key and suffix (default = "").

suffix

Optional. A string to include at the end of the newly calculated scale variables' names, after Abbrev from key and prefix (default = "").

Value

A data frame that matches .data except that new variables are appended that contain mean scores on each variable included in key.

See also

Other tidying functions: ipsatize(), standardize()

Examples

data("raw_iipsc")
instrument("iipsc")
score(raw_iipsc, IIP01:IIP32, iipsc)
#> # A tibble: 10 × 40
#>    IIP01 IIP02 IIP03 IIP04 IIP05 IIP06 IIP07 IIP08 IIP09 IIP10 IIP11 IIP12 IIP13
#>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1     0     0     0     0     1     0     1     0     2     1     0     0     0
#>  2     1     1     0     0     3     2     2     1     0     1     0     1     4
#>  3     1     0     1     0     1     1     1     3     0     1     0     0     2
#>  4     3     2     3    NA     2     3     2     3     2     3     2     4     2
#>  5     0     0     0     1     0     0     1     1     0     1     0     2     1
#>  6     0     0     0     0     0     0     1     1     0     0     0     0     0
#>  7     1     0     0     0     2     1     1     0     1     0     0     0     1
#>  8     1     0     1     0     1     1     2     1     1     0     0     0     1
#>  9     0     0     2     2     0     1     3     0     1     0     1     1     0
#> 10     0     0     0     0     0     0     2     0     0     0     0     0     0
#> # ℹ 27 more variables: IIP14 <dbl>, IIP15 <dbl>, IIP16 <dbl>, IIP17 <dbl>,
#> #   IIP18 <dbl>, IIP19 <dbl>, IIP20 <dbl>, IIP21 <dbl>, IIP22 <dbl>,
#> #   IIP23 <dbl>, IIP24 <dbl>, IIP25 <dbl>, IIP26 <dbl>, IIP27 <dbl>,
#> #   IIP28 <dbl>, IIP29 <dbl>, IIP30 <dbl>, IIP31 <dbl>, IIP32 <dbl>, PA <dbl>,
#> #   BC <dbl>, DE <dbl>, FG <dbl>, HI <dbl>, JK <dbl>, LM <dbl>, NO <dbl>