| CompScoreTable {stenR} | R Documentation |
R6 class for producing easily re-computable ScoreTable
Description
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.
Methods
Public methods
Method new()
Initialize a CompScoreTable object. You can attach one or many
StandardScale and FrequencyTable objects
Usage
CompScoreTable$new(tables = NULL, scales = NULL)
Arguments
tablesNamed list of
FrequencyTableobjects to be attached. Names will indicate the name of variable for which the table is calculated. Defaults toNULL, so no tables will be available at the beginning.scalesStandardScaleobject or list of such objects to be attached. They will be used for calculation ofScoreTables.Defaults toNULL, so no scales wil be available at the beginning.
Details
Both FrequencyTable and StandardScale objects can be attached
with appropriate methods after object initialization.
Returns
CompScoreTable object
Method attach_StandardScale()
Attach new scale to the object. If there are any ScoreTables already computed, score for newly-attached scale will be computed automatically.
Usage
CompScoreTable$attach_StandardScale(scale, overwrite = FALSE)
Arguments
scaleStandardScaleobject defining a scaleoverwriteboolean indicating if the definition for a scale of the same name should be overwritten
Method attach_FrequencyTable()
Attach previously generated FrequencyTable for a given
variable. ScoreTable containing every attached scale will be calulcated
automatically based on every new FrequencyTable.
Usage
CompScoreTable$attach_FrequencyTable(
ft,
var,
if_exists = c("stop", "append", "replace")
)Arguments
ftFrequencyTable to be attached
varString with the name of the variable
if_existsAction that should be taken if
FrequencyTablefor given variable already exists in the object.-
stopDEFAULT: don't do anything -
appendrecalculates existing table -
replacereplaces existing table
-
Method export_ScoreTable()
Export list of ScoreTables from the object
Usage
CompScoreTable$export_ScoreTable(vars = NULL, strip = FALSE)
Arguments
varsNames of the variables for which to get the tables. If left at
NULLdefault - get all off them.striplogical indicating if the
ScoreTablesshould be stripped down toFrequencyTablesduring export. Defaults toFALSE
Returns
list of ScoreTable or FrequencyTable object
Method 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).
Usage
CompScoreTable$standardize(data, what, vars = names(data), calc = FALSE)
Arguments
datadata.frame containing raw scores.
whatthe 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
CompScoreTableobject
-
varsvector of variable names which will taken into account
calcshould the
ScoreTablesbe computed (or recalculated, if some are already provided?). Default toTRUE
Returns
data.frame with standardized values
Method clone()
The objects of this class are cloneable with this method.
Usage
CompScoreTable$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.