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. |
Authors: | Paul F. Petrowski <[email protected]> |
Maintainer: | Paul F. Petrowski <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1 |
Built: | 2025-02-19 03:13:30 UTC |
Source: | https://github.com/pfpetrowski/rsnell |
This function will be used to convert the raw data from the database to count data that can be passed into the snell function.
buildfreqtable(data, trait, subgroup, order)
buildfreqtable(data, trait, subgroup, order)
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 |
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.
A frequency table with the specified subgroup as the rownames, the scores of the specified trait as column names, and count as values
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")
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")
This function calculates Snell scores given counts of scores by subpopulation
snell(table)
snell(table)
table |
a frequency table with group labels in rows and the original scores in columns. This can be derived using the buildfreqtable function. |
a vector of scores corresponding to the columns of the input frequency table.
http://140.136.247.242/~stat2016/stat/NoteOnSnellComp.pdf
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)
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)