Version: | 0.1 |
Date: | 2023-02-18 |
Title: | Snell Scoring |
Description: | The Snell scoring procedure, implemented in R. This procedure was first described by E.J Snell (1964) <doi:10.2307/2528498> and was later used by Tong et al (1977) <doi:10.4141/cjas77-001> in dairy. |
Author: | Paul F. Petrowski <pfpetrowski@gmail.com> |
Maintainer: | Paul F. Petrowski <pfpetrowski@gmail.com> |
RoxygenNote: | 7.2.1 |
License: | MIT + file LICENSE |
Imports: | dplyr, tidyr, tibble, tidyselect |
URL: | https://github.com/pfpetrowski/rsnell |
Encoding: | UTF-8 |
NeedsCompilation: | no |
Packaged: | 2023-02-27 04:21:44 UTC; paulpetrowski |
Repository: | CRAN |
Date/Publication: | 2023-02-27 16:42:29 UTC |
Convert raw data to count data for use in snell function
Description
This function will be used to convert the raw data from the database to count data that can be passed into the snell function.
Usage
buildfreqtable(data, trait, subgroup, order)
Arguments
data |
A data frame containing the raw data |
trait |
A character string specifying the trait to be analyzed |
subgroup |
A character string specifying the column containing the grouping variable |
order |
A character vector specifying the order in which the categories of the trait should be placed |
Details
This function groups the data by the specified subgroup and trait, and counts the occurrences for each combination. It then reshapes the data into a frequency table.
Value
A frequency table with the specified subgroup as the rownames, the scores of the specified trait as column names, and count as values
Examples
library(dplyr)
mydata <- data.frame("Groups" = rep(c("A", "B", "C", "D"), 10),
"Scores" = round(runif(40, 0, 5)))
buildfreqtable(data = mydata, trait = "Scores", subgroup = "Groups")
Calculate Snell scores
Description
This function calculates Snell scores given counts of scores by subpopulation
Usage
snell(table)
Arguments
table |
a frequency table with group labels in rows and the original scores in columns. This can be derived using the buildfreqtable function. |
Value
a vector of scores corresponding to the columns of the input frequency table.
References
http://140.136.247.242/~stat2016/stat/NoteOnSnellComp.pdf
Examples
library(dplyr)
mydata <- data.frame("Groups" = rep(c("A", "B", "C", "D"), 10),
"Scores" = round(runif(40, 0, 5)))
freqtable <- buildfreqtable(data = mydata, trait = "Scores", subgroup = "Groups")
snell(freqtable)