factorize_desc | R Documentation |
Turns descriptive columns separated by tpbudget::sep_budget into factor columns ordered by the number of the column. For instance, turns "department_desc" column describing departments into factor column in order of department_num (the department number associated with the description; e.g., 1000, 2000, 3000, 4000). Useful for representing the descriptive component of the column in tables/visualizations in a logical order.
factorize_desc(df, basename, .suffix = "_desc")
df |
A Tyler Extract Report dataframe, likely processed by sep_budget |
basename |
The string-name of the base column that's also been separated into numeric and descriptive columns. For instance, "department" would have it's own column as well as a "department_desc" column with the text-name of the department and a "department_num" column with the number of the department. Function assumes that base column is still present in dataframe, consisting of number/description combination (e.g., "1000 General Government", "40 Personnel"). |
.suffix |
Suffix of the column with the descriptive portion of the basename; default "_desc." Assumes name of descriptive-column is combination of basename and .suffix. |
A dataframe with a descriptive column as a factor
{ a <- data.frame("department" = c("1000 General Government", "2000 Police", "3000 Public Works")) # now has a department_num and department_desc column a <- tpbudget::sep_budget(a, "department") factorize_desc(a, "department") # works without numeric column so long as basename column is structured in "number text" format factorize_desc(dplyr::select(a, -department_num), "department") a_rename <- dplyr::rename(a, "departmentdescriptive" = "department_desc") # change suffix to match factorize_desc(a_rename, "department", "descriptive") }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.