View source: R/buildfreqtable.R
| buildfreqtable | R Documentation |
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)
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.