buildfreqtable {rsnell} | R Documentation |
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")
[Package rsnell version 0.1 Index]