Skip to contents

jlikert() declares one or more value-labelled variables as Likert items – ordered response scales (for example 1 = Strongly disagree through 5 = Strongly agree). It is the ordered-scale counterpart to jdummy (categorical), jnumeric (continuous), and jcount (count): a variable carries exactly one registered intent at a time, so registering it as Likert clears any prior numeric, count, or dummy registration on it.

Usage

jlikert(data, ..., remove = FALSE, clear.all = FALSE)

Arguments

data

A data frame, or omitted to use the juse default. Registrations are stored under the data frame's name, so it is given as a name (or as a place such as lst$d); an expression that builds one is refused, with the two lines that name it first. The NULL and remove = TRUE forms work on a name whose data frame has since been removed.

...

One or more unquoted variable names to register, or a single NULL to clear this frame's Likert registrations (see Details). The registration applies to numeric variables and to haven-labelled variables that hold numbers. Any other type is refused, and none of the call's variables is then registered: convert a factor or a text variable to numbers first with jencode.

remove

Logical; if TRUE, remove the named variables' Likert registrations instead of adding them.

clear.all

Logical; if TRUE, clear Likert registrations on every data frame.

Value

Invisibly NULL. Called for its side effect on the session registry.

Details

Scope – display only. The Likert intent refines reporting, not analysis. It sets the variable's sub-class to "Likert" in jscreen's Variable Types table, marking it as an ordered scale rather than a generic N-category variable. It does NOT change how any analysis treats the variable (there is no order-aware modelling), and it does not by itself change jplot output – a value-labelled small-range variable already plots as an ordered, labelled bar regardless of this registration.

Like the other registration verbs, registrations are session-scoped and keyed by data-frame name; save the frame in R format (.rds) with jsave to keep them across sessions.

Clearing mirrors the other registration verbs:

  • jlikert(data, NULL) – clear this frame's Likert registrations.

  • jlikert(NULL) – clear the juse() default frame (or the sole frame carrying Likert registrations; if several do, it asks rather than clearing them all).

  • jlikert(clear.all = TRUE) – clear every frame.

jlikert() with no arguments prints the current registration status.

Examples

  jlikert(community, Environment1, Environment2)  # declare two Likert items
#> Likert registration set for 'Environment1', 'Environment2' in community.
#> Note: registrations are stored for this session only.
#> To keep them across sessions, save the data frame in R format (.rds):
#>   jsave(community, "community.rds")
#> 
#> Next session, load that file to restore the registrations:
#>   jload("community.rds")
  jlikert(data = community, Environment1)         # the data frame by name
#> Likert registration set for 'Environment1' in community.
#> Note: this registration is stored for this session only.
#> To keep it across sessions, save the data frame in R format (.rds):
#>   jsave(community, "community.rds")
#> 
#> Next session, load that file to restore the registration:
#>   jload("community.rds")
  juse(community); jlikert(Environment1); juse(NULL)  # or the juse() default
#> Default data frame set to: community
#> Using default data frame: community
#> Likert registration set for 'Environment1' in community.
#> Note: this registration is stored for this session only.
#> To keep it across sessions, save the data frame in R format (.rds):
#>   jsave(community, "community.rds")
#> 
#> Next session, load that file to restore the registration:
#>   jload("community.rds")
#> Default data frame cleared.
  jscreen(community)                              # Sub-class shows "Likert"
#> Data Screening
#>   Cases: 103
#>   Variables: 15
#>   Cases with missing data: 34
#>   Variables with outliers: 0
#> 
#> Variable Types
#> Variable        jstats Class  Sub-class   Source         Unique Values
#> --------------  ------------  ----------  -------------  -------------
#> RespondentID    Categorical   identifier                      103
#> Income          Numeric                                        49
#> Education       Categorical   5-category                        5
#> Age             Numeric                                        41
#> WellbeingScore  Numeric                                        41
#> Volunteer       Categorical   dichotomy                         2
#> OwnsHome        Categorical   dichotomy*                        2
#> Smoker          Categorical   dichotomy                         2
#> CommuteTime     Numeric                                        42
#> Region          Categorical   4-category                        4
#> Environment1    Categorical   Likert      User-declared         5
#> Environment2    Categorical   Likert      User-declared         5
#> Environment3    Categorical   Likert                            5
#> Environment4    Categorical   Likert                            5
#> Environment5    Categorical   Likert                            5
#> * coded other than 0/1; mean is not a proportion
#> 
#> Missing Data & Outliers (outliers > 3 SD from mean)
#> Variable      Missing  % Missing
#> ------------  -------  ---------
#> Income            6        5.8
#> Education         6        5.8
#> Smoker            5        4.9
#> Environment1     12       11.7
#> Environment3     12       11.7
#> 
#> Note: SPSS-style declared missing values on: Income, Education, Smoker,
#> Environment1, Environment3.
#> jstats treats these as missing; base R functions do not.
#> 
  jlikert(community, Environment1, remove = TRUE) # undo one
#> Likert registration removed for 'Environment1' in community.
  jlikert(community, NULL)                        # clear the registrations
#> Likert registrations cleared for community: Environment2.