normalize_scores_grouped | R Documentation |
Normalize scores using either GroupedFrequencyTable
or
GroupedScoreTable
for one or more variables. Given data.frame should also
contain columns used in GroupingConditions
attached to the table
normalize_scores_grouped( data, vars, ..., what, retain = FALSE, group_col = NULL, .dots = list() )
data |
data.frame object containing raw scores |
vars |
names of columns to normalize. Length of vars
need to be the same as number of tables provided to either |
... |
|
what |
the values to get. One of either:
|
retain |
either boolean: |
group_col |
name of the column for name of the group each
observation was qualified into. If left as default |
.dots |
|
data.frame with normalized scores
Other score-normalization functions:
normalize_scores_df()
,
normalize_scores_scoring()
,
normalize_score()
# setup - create necessary objects # suppressMessages({ age_grouping <- GroupConditions( conditions_category = "Age", "below 22" ~ age < 22, "23-60" ~ age >= 23 & age <= 60, "above 60" ~ age > 60 ) sex_grouping <- GroupConditions( conditions_category = "Sex", "Male" ~ sex == "M", "Female" ~ sex == "F" ) NEU_gft <- GroupedFrequencyTable( data = IPIP_NEO_300, conditions = list(age_grouping, sex_grouping), var = "N" ) NEU_gst <- GroupedScoreTable( NEU_gft, scale = list(STEN, STANINE) ) }) #### normalize scores #### # to Z score or quantile using GroupedFrequencyTable normalized_to_quan <- normalize_scores_grouped( IPIP_NEO_300, vars = "N", NEU_gft, what = "quan", retain = c("sex", "age") ) # only 'sex' and 'age' are retained head(normalized_to_quan) # to StandardScale attached to GroupedScoreTable normalized_to_STEN <- normalize_scores_grouped( IPIP_NEO_300, vars = "N", NEU_gst, what = "stanine", retain = FALSE, group_col = "sex_age_group" ) # none is retained, 'sex_age_group' is created head(normalized_to_STEN)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.