This function reorders the levels of a factor based on the sentiment scores of the levels. Using this function can be expensive (depending on the LLM used and user's computer spec) so users may wish to use this interactively only and copy the output into their script.
Arguments
- .f
A character vector that is assumed to be an ordinal factor.
- copy
A logical value to indicate whether the output should be copied into the user's clipboard.
Examples
# to get the new level order
# users should check if the new order
sai_lvl_order(likerts$likert1)
#> [1] "Strongly Disagree" "Disagree" "Somewhat Disagree"
#> [4] "Neutral" "Somewhat Agree" "Agree"
#> [7] "Strongly Agree"
# `copy = TRUE` copies the output into clipboard in a format that can be
# entered easiliy in the user's script
sai_lvl_order(likerts$likert1, copy = TRUE)
#> [1] "Strongly Disagree" "Disagree" "Somewhat Disagree"
#> [4] "Neutral" "Somewhat Agree" "Agree"
#> [7] "Strongly Agree"
# to apply the new levels directly to the input
sai_fct_reorder(likerts$likert1)
#> [1] Strongly Disagree Neutral Strongly Agree Strongly Disagree
#> [5] Disagree Somewhat Agree Strongly Agree Somewhat Disagree
#> [9] Agree Disagree Somewhat Disagree Somewhat Disagree
#> [13] Strongly Disagree Somewhat Agree Somewhat Agree Disagree
#> [17] Agree Agree Disagree Strongly Agree
#> [21] Strongly Disagree Strongly Agree Somewhat Agree Somewhat Agree
#> [25] Strongly Disagree Strongly Disagree Agree Somewhat Agree
#> [29] Somewhat Agree Disagree Disagree Agree
#> [33] Strongly Disagree Neutral Strongly Agree Strongly Disagree
#> [37] Neutral Somewhat Disagree Agree Disagree
#> 7 Levels: Strongly Disagree Disagree Somewhat Disagree ... Strongly Agree