Computable ScoreTable class. It can compute and store
ScoreTables
for multiple variables containing raw score results.
After computation, it could be also used to compute new standardized scores for provided raw scores and integrate them into stored tables.
summary()
function can be used to get general information about
CompScoreTable
object.
new()
Initialize a CompScoreTable
object. You can attach one or many
StandardScale
and FrequencyTable
objects
CompScoreTable$new(tables = NULL, scales = NULL)
tables
Named list of FrequencyTable
objects to be attached. Names
will indicate the name of variable for which the table is calculated.
Defaults to NULL
, so no tables will be available at the beginning.
scales
StandardScale
object or list of such objects to be attached.
They will be used for calculation of ScoreTables.
Defaults to NULL
, so no
scales wil be available at the beginning.
Both FrequencyTable
and StandardScale
objects can be attached
with appropriate methods after object initialization.
CompScoreTable object
attach_StandardScale()
Attach new scale to the object. If there are any ScoreTables already computed, score for newly-attached scale will be computed automatically.
CompScoreTable$attach_StandardScale(scale, overwrite = FALSE)
scale
StandardScale
object defining a scale
overwrite
boolean indicating if the definition for a scale of the same name should be overwritten
attach_FrequencyTable()
Attach previously generated FrequencyTable
for a given
variable. ScoreTable
containing every attached scale will be calulcated
automatically based on every new FrequencyTable
.
CompScoreTable$attach_FrequencyTable(
ft,
var,
if_exists = c("stop", "append", "replace")
)
ft
FrequencyTable to be attached
var
String with the name of the variable
if_exists
Action that should be taken if FrequencyTable
for
given variable already exists in the object.
stop
DEFAULT: don't do anything
append
recalculates existing table
replace
replaces existing table
export_ScoreTable()
Export list of ScoreTables
from the object
CompScoreTable$export_ScoreTable(vars = NULL, strip = FALSE)
vars
Names of the variables for which to get the tables.
If left at NULL
default - get all off them.
strip
logical indicating if the ScoreTables
should be stripped
down to FrequencyTables
during export. Defaults to FALSE
list of ScoreTable
or FrequencyTable
object
standardize()
Compute standardize scores for data.frame
of raw scores.
Additionally, the raw scores can be used to recalculate ScoreTables
before computing (using calc = T
).
CompScoreTable$standardize(data, what, vars = names(data), calc = FALSE)
data
data.frame containing raw scores.
what
the values to get. One of either:
quan
- the quantile of raw score in the distribution
Z
- normalized Z score for the raw scores
name of the scale attached to the CompScoreTable
object
vars
vector of variable names which will taken into account
calc
should the ScoreTables
be computed (or recalculated, if
some are already provided?). Default to TRUE
data.frame
with standardized values
clone()
The objects of this class are cloneable with this method.
CompScoreTable$clone(deep = FALSE)
deep
Whether to make a deep clone.