All high-level functions use standard R model formulas:
response ~ factorA + factorB + factorC
+ lists the main effects.A:B or A*B.~) must be numeric (e.g., a
Likert score coded as 1 to 5 and stored as numeric).Examples below use the included dataset mimicry.
library(factorH)
data(mimicry, package = "factorH")
str(mimicry)
Predictors should be factors. If they are not, the functions will coerce them to factors internally.
What is allowed?
# One factor (KW-style):
liking ~ condition
# Two factors (SRH-style):
liking ~ gender + condition
# Three or more factors (k-way):
liking ~ gender + condition + age_cat
You do not need to write gender:condition or
gender*condition. The package constructs the required
interaction terms internally when needed.
The response must be numeric. For Likert-type responses (e.g., 1 = strongly disagree, …, 5 = strongly agree), keep the variable numeric. Rank-based procedures can be used with such ordinal-like data.
If a Likert variable has been imported as a factor or character, coerce it safely:
# if stored as character "1", "2", ...:
mimicry$liking <- as.numeric(mimicry$liking)
# if stored as factor with labels "1", "2", ...:
mimicry$liking <- as.numeric(as.character(mimicry$liking))
C:0u34e45b057346-syntax.R