# Roger Palay copyright 2016-01-31 # Saline, MI 48176 # make_freq_table <- function( lcl_list ) { ## This function will create a frequency table for ## the one variable sent to it where that ## table gives the items, the frequency, the relative ## frequeny, the cumulative frequency, the relative ## cumulative frequency, and the number of degrees to ## allocate in a pie chart. ## ## The actual result of this function is a data frame ## holding that table. lcl_freq <- table( lcl_list ) lcl_size <- length( lcl_list ) lcl_df <- data.frame( lcl_freq ) names( lcl_df ) <- c("Items","Freq") lcl_values <- as.numeric( lcl_freq ) lcl_df$rel_freq <- lcl_values / lcl_size lcl_df$cumul_freq <- cumsum( lcl_values ) lcl_df$rel_cumul_freq <- cumsum( lcl_values ) / lcl_size lcl_df$pie <- round( 360*lcl_df$rel_freq, 1 ) lcl_df }