Package 'rsnell'

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

Help Index


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)