Title: | Supplies essential functions to Teaching Lab dashboards |
---|---|
Description: | A bunch of random functions I use in developing dashboards Needs to vastly reduce the number of dependencies at the moment. |
Authors: | Duncan Gates |
Maintainer: | Duncan Gates <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-01 06:11:05 UTC |
Source: | https://github.com/teachinglab/tlShiny |
Gets the percent that agree and strongly agree
agree_strongly_agree(data, question)
agree_strongly_agree(data, question)
data |
the data |
question |
a string - the question to get the percentage for |
a string
## Not run: plot_agree |> agree_strongly_agree(question = "x") ## End(Not run)
## Not run: plot_agree |> agree_strongly_agree(question = "x") ## End(Not run)
Calculate nps score
calc_nps(x)
calc_nps(x)
x |
A vector of nps scores |
Returns the nps score With formula '
Verifies that an email is in a list
check_email_approved(email, approved_emails_list)
check_email_approved(email, approved_emails_list)
email |
the email provided |
approved_emails_list |
the email to check the list for |
TRUE or FALSE
Verifies that an email is of a specified domain
check_email_domain(email, domain)
check_email_domain(email, domain)
email |
the email provided |
domain |
the domain to check that it is from |
TRUE or FALSE
Returns a barchart for selections in the relevant questions of the contact lead survey
contact_lead_graph(data)
contact_lead_graph(data)
data |
the data to use |
prints a ggplot object
Returns a barchart for selections in the relevant questions of the end of coaching survey
course_feedback_graph(data)
course_feedback_graph(data)
data |
the data to use |
prints a ggplot object
Creates a button that will expand or hide content
drop1(before = T, options, envir, name)
drop1(before = T, options, envir, name)
before |
button default, collapsed/not collapsed |
options |
unclear |
envir |
also unclear |
name |
chunk name |
html wrapper
Returns a barchart for selections in the relevant questions of the end of coaching survey
end_coaching_feedback_graph(data)
end_coaching_feedback_graph(data)
data |
the data to use |
prints a ggplot object
Gives the file path without double slash bug
file.path2(..., fsep = .Platform$file.sep)
file.path2(..., fsep = .Platform$file.sep)
... |
The file path |
fsep |
the file separation |
fp a file path
function for grading different parts of the ipg forms
grade_ipg(x, type = "character")
grade_ipg(x, type = "character")
x |
the data |
type |
character or numeric |
a percentage of correct either by checking 3 or 4 or yes
makes a gt table with percent and n colored
gt_percent_n( df, column, custom_title, no_title = T, base_font = 10, heading_font = 14, custom_column_name = "", viz_type = "gt" )
gt_percent_n( df, column, custom_title, no_title = T, base_font = 10, heading_font = 14, custom_column_name = "", viz_type = "gt" )
df |
the data frame |
column |
the column to get count and percent from |
custom_title |
the title for the table |
no_title |
make the table have no title |
base_font |
overall table font size |
heading_font |
title font size |
custom_column_name |
a custom name for the column |
viz_type |
gt by default, also has ggplot options like pie chart, waffle, or treemap |
a gt table
Create Teaching Lab theme to a gt table
gt_theme_tl( data, all_caps = F, align = "center", base_font = 16, heading_font = 20, ... )
gt_theme_tl( data, all_caps = F, align = "center", base_font = 16, heading_font = 20, ... )
data |
An existing gt table object |
all_caps |
Whether or not to capitalize titles |
align |
Align options are "left", "center", "right" |
base_font |
the font size |
heading_font |
the title font size |
... |
Optional additional arguments to gt::table_options() |
Creates a gt theme as a pipeable function
mtcars |> utils::head() |> gt::gt() |> tlShiny::gt_theme_tl()
mtcars |> utils::head() |> gt::gt() |> tlShiny::gt_theme_tl()
Helper function to extract a grob from gtables by name.
gtable_extract_grob(g, pattern = "guide-box")
gtable_extract_grob(g, pattern = "guide-box")
g |
the gtable to extract the grob |
pattern |
grob name or pattern to match |
g, a grob matching the specified pattern
Helper function to remove grobs by name, from gtables
gtable_remove_grob(g, pattern = "guide-box")
gtable_remove_grob(g, pattern = "guide-box")
g |
gtable with the grob removed |
pattern |
grob name or pattern to match |
g, with pattern removed.
Provides html formatted highlighting
highlight_fun(data, highlight = tlShiny::find_highlight(data))
highlight_fun(data, highlight = tlShiny::find_highlight(data))
data |
the data to highlight |
highlight |
the words to highlight |
#' @title Word highlighting #' @description Finds most common words in string #' @param string the string to evaluate #' @param n the number of words to find #' @param print whether or not to print the highlighted words #' @return a vector of strings #' #' @export find_highlight <- function(string, n = 3, print = F) stop_words <- tlShiny::stop_words |> dplyr::bind_rows(data.frame(word = tlShiny::na_df, lexicon = "TL_NA"))
txt_df <- data.frame(column_name = "txt") |>
highlight <- string |> na.omit() |> as.data.frame() |> dplyr::rename() |> tidytext::unnest_tokens(word, txt) |> # This makes sure to get rid of numbers in consideration for highlighting # By making sure as.numeric returns NA on words dplyr::filter(is.na(as.numeric(word))) |> # Get a count of words and sort dplyr::count(word, sort = T) |> # Get rid of generic (stop) words dplyr::anti_join(stop_words) |> # Get a user-specified number of words, or the default 3 utils::head(n) |> # Make this a vector dplyr::pull(word) |> # Suppress warnings from the as.numeric call suppressWarnings() |> suppressMessages()
if (print == T) print(highlight)
return(highlight)
a vector of strings
Takes a string and inserts <br> at the requested intervals
html_wrap(string, n = 40)
html_wrap(string, n = 40)
string |
the string |
n |
the width of the string before a <br> tag |
the same string with <br> inserted at the requested interval
html_wrap("a random string that has about 40 characters in it")
html_wrap("a random string that has about 40 characters in it")
Creates a graph specifically for Knowledge Assessments in mid year reports
know_assess_summary(data, know_assess_filter)
know_assess_summary(data, know_assess_filter)
data |
the data |
know_assess_filter |
the knowledge assessment to make plot for |
a ggplot
Creates a graph specifically for Knowledge Assessments Scored by Question from Qualtrics
know_assess_summary_detailed(data, know_assess)
know_assess_summary_detailed(data, know_assess)
data |
the data |
know_assess |
the knowledge assessment to make plot for |
a ggplot
Creates a chart to summarise the ELA IPG based on the round selected
make_ipg_ela_summary_chart( data, round = "Baseline (first observation of the year)" )
make_ipg_ela_summary_chart( data, round = "Baseline (first observation of the year)" )
data |
the data |
round |
the round of the IPG for which data should be pulled (can be one of "Baseline (first observation of the year)", "Mid-year (middle of service, if applicable)", "End of year (last observation of the year)", "Other", or "Ongoing") |
a ggplot
Creates a chart to summarise the FSOT IPG based on the round selected
make_ipg_fsot_summary_chart( data, round = "Baseline (first observation of the year)" )
make_ipg_fsot_summary_chart( data, round = "Baseline (first observation of the year)" )
data |
the data |
round |
the round of the IPG for which data should be pulled (can be one of "Baseline (first observation of the year)", "Mid-year (middle of service, if applicable)", "End of year (last observation of the year)", "Other", or "Ongoing") |
a ggplot
Creates a chart to summarise the Math IPG based on the round selected
make_ipg_math_summary_chart( data, round = "Baseline (first observation of the year)" )
make_ipg_math_summary_chart( data, round = "Baseline (first observation of the year)" )
data |
the data |
round |
the round of the IPG for which data should be pulled (can be one of "Baseline (first observation of the year)", "Mid-year (middle of service, if applicable)", "End of year (last observation of the year)", "Other", or "Ongoing") |
a ggplot
Chart to show the
make_student_work_chart_circle(data)
make_student_work_chart_circle(data)
data |
the data for the plotter to use, should include all columns of interest |
a ggplot
Chart to show the
make_student_work_chart_people(data)
make_student_work_chart_people(data)
data |
the data for the plotter to use, should include all columns of interest |
a ggplot
Creates a chart to summarise the teacher perceptions of curriculum
make_teacher_curriculum_perceptions(data)
make_teacher_curriculum_perceptions(data)
data |
the data |
a ggplot
Creates a chart to summarise the Teacher Curriculum Usage from the Educator Survey
make_teacher_curriculum_usage(data)
make_teacher_curriculum_usage(data)
data |
the data |
a ggplot
Creates a chart to summarise the teacher use of lessons from district or school-adopted materials
make_teacher_lesson_usage(data)
make_teacher_lesson_usage(data)
data |
the data |
a ggplot
Creates a chart to summarise the teacher perceptions of of peer relationships
make_teacher_perceptions_peer_relationships(data)
make_teacher_perceptions_peer_relationships(data)
data |
the data |
a ggplot
Creates a chart to summarise the teacher perceptions of school leaders
make_teacher_perceptions_school_leaders(data)
make_teacher_perceptions_school_leaders(data)
data |
the data |
a ggplot
A list of NA type words to ignore in qualitative responses
na_df
na_df
A character vector
Conditionally filters value given that it is not the first parameter, for use in shiny apps
neg_cond_filter(data, if_not_this, filter_this, dat_filter)
neg_cond_filter(data, if_not_this, filter_this, dat_filter)
data |
the dataframe to apply filter |
if_not_this |
If value is not this |
filter_this |
Filter for this |
dat_filter |
Data column object to filter |
filtered dataframe
A plot that says no data available yet this year
no_data_plot_currently
no_data_plot_currently
An object of class gg
(inherits from ggplot
) of length 11.
A plot that says no data available by default, but can be adjusted to say whatever you want
no_data_plot_custom(title = "No data available!")
no_data_plot_custom(title = "No data available!")
A plot that says no data available, and to check your filters
no_data_plot_filters
no_data_plot_filters
An object of class gg
(inherits from ggplot
) of length 11.
Find elements x not in a vector y
x %!in% y
x %!in% y
x |
A vector of what shouldn't exist |
y |
A vector to check against |
Returns elements not in vector
Returns a barchart for selections in the relevant questions of the end of coaching survey
ongoing_coaching_feedback_graph(data)
ongoing_coaching_feedback_graph(data)
data |
the data to use |
prints a ggplot object
takes a dataframe and makes a gt table or ggplot that shows a quote
quote_viz( data, text_col = colnames(data)[1], viz_type = "gt", custom_highlight = NULL, n = 3, print = T, width = 60, title = NULL, suppress_warnings = T, align = "center", save = T, ... )
quote_viz( data, text_col = colnames(data)[1], viz_type = "gt", custom_highlight = NULL, n = 3, print = T, width = 60, title = NULL, suppress_warnings = T, align = "center", save = T, ... )
data |
the dataframe |
text_col |
columns to create table for |
viz_type |
ggplot or gt visualization |
custom_highlight |
a vector, optional custom highlighting |
n |
integer, number of words to auto-highlight |
print |
T, whether or not to print the highlighted words to console |
width |
The width of the table generated |
title |
the title of the ggplot or gt |
suppress_warnings |
T/F suppression of warnings |
align |
the table alignment: "left", "center", "right" |
... |
Arguments passed onto the gt table |
a ggplot/gt that visualizes text
## Not run: df <- tlShiny::survey_monkey colnames(df)[1] <- "What learning are you excited to try?" quote_viz( data = df, text_col = "What learning are you excited to try?", viz_type = "gt", title = "Responses from Survey Monkey" ) ## End(Not run)
## Not run: df <- tlShiny::survey_monkey colnames(df)[1] <- "What learning are you excited to try?" quote_viz( data = df, text_col = "What learning are you excited to try?", viz_type = "gt", title = "Responses from Survey Monkey" ) ## End(Not run)
Filters out all rows that contain entirely NA
remove_empty_tl(data)
remove_empty_tl(data)
data |
the dataframe to apply filter |
a dataframe with no empty rows
See tl_palette()
.
scale_colour_tl(n, color = "blue", ...) scale_color_tl(n, color = "blue", ...) scale_fill_tl( n, color = c("blue", "orange", "purple", "green", "teal", "tl_colors"), ... )
scale_colour_tl(n, color = "blue", ...) scale_color_tl(n, color = "blue", ...) scale_fill_tl( n, color = c("blue", "orange", "purple", "green", "teal", "tl_colors"), ... )
n |
the number of colors |
color |
the color from |
... |
Arguments passed on to
|
Returns a barchart for selections in the relevant questions of the end of coaching survey
session_feedback_graph(data)
session_feedback_graph(data)
data |
the data to use |
prints a ggplot object
This function computes the square of a numeric input.
square(x)
square(x)
x |
A numeric input. |
The square of the input.
tlShiny::square(2) tlShiny::square(3.5)
tlShiny::square(2) tlShiny::square(3.5)
English stop words from three lexicons, as a data frame. The snowball and SMART sets are pulled from the tm package. Note that words with non-ASCII characters have been removed.
stop_words
stop_words
A data frame with 1149 rows and 2 variables:
An English word
The source of the stop word. Either "onix", "SMART", or "snowball"
Automatically dodged bar chart for student data
student_bar_chart( data, col_select, agree_select, string_remove, title, legend_position = c(0.8, 0.25) )
student_bar_chart( data, col_select, agree_select, string_remove, title, legend_position = c(0.8, 0.25) )
data |
the data for the plotter to use, should include all columns of interest |
col_select |
the columns to select with 'tidyselect::contains' |
agree_select |
the type of agree/strongly agree to select, for example also often/always |
string_remove |
NULL by default, provides an optional string removal |
title |
the title for the plot |
legend_position |
c(0.8, 0.25) by default, adjustable |
a ggplot object
All Subsites as currently named in Qualtrics Reference Survey
A vector of subsite names
Survey monkey reviews from the course survey in response to the question What is the learning from this course that you are most excited about trying out?, as a data frame.
survey_monkey
survey_monkey
A data frame with 87 rows and 1 variable:
A deidentified review in each row
@source https://www.surveymonkey.com/r/TLendofcourse
Teaching Lab Custom Ggplot2 Theme
theme_tl( base_family = "Calibri", base_size = 14, strip_text_family = base_family, strip_text_size = 15, plot_title_family = "Calibri", plot_title_size = 20, plot_title_margin = 10, subtitle_family = "Roboto", subtitle_size = 15, subtitle_margin = 15, caption_family = "Roboto", caption_size = 11, caption_margin = 10, axis_title_family = "Calibri", axis_title_size = 12, axis_title_just = "mm", axis_text_size = 10.5, dark = FALSE, grid = TRUE, axis = FALSE, ticks = FALSE, markdown = FALSE, legend = F )
theme_tl( base_family = "Calibri", base_size = 14, strip_text_family = base_family, strip_text_size = 15, plot_title_family = "Calibri", plot_title_size = 20, plot_title_margin = 10, subtitle_family = "Roboto", subtitle_size = 15, subtitle_margin = 15, caption_family = "Roboto", caption_size = 11, caption_margin = 10, axis_title_family = "Calibri", axis_title_size = 12, axis_title_just = "mm", axis_text_size = 10.5, dark = FALSE, grid = TRUE, axis = FALSE, ticks = FALSE, markdown = FALSE, legend = F )
base_family |
base font family |
base_size |
base font size |
strip_text_family |
facet label font family |
strip_text_size |
facet label text size |
plot_title_family |
plot title family |
plot_title_size |
plot title font size |
plot_title_margin |
plot title margin |
subtitle_family |
plot subtitle family |
subtitle_size |
plot subtitle size |
subtitle_margin |
plot subtitle margin |
caption_family |
plot caption family |
caption_size |
plot caption size |
caption_margin |
plot caption margin |
axis_title_family |
axis title font family |
axis_title_size |
axis title font size |
axis_title_just |
axis title font justification |
axis_text_size |
axis text size |
dark |
dark mode |
grid |
panel grid ( |
axis |
axis |
ticks |
ticks |
markdown |
enabled ggtext markdown styling |
legend |
default no legend with F |
It requires installing Roboto, Calibri fonts unless you change the font parameters
TL Default Blue Palette
tl_pal_blue
tl_pal_blue
An object of class character
of length 8.
Teaching Lab Color Palette Maker
tl_palette( color = c("blue", "orange", "purple", "green", "teal", "tl_colors"), theme = c("dark"), n = 6, base_color_start = NULL )
tl_palette( color = c("blue", "orange", "purple", "green", "teal", "tl_colors"), theme = c("dark"), n = 6, base_color_start = NULL )
color |
the color palette to generate |
theme |
if theme is light or dark |
n |
number of colors to generate |
base_color_start |
the base color of the palette to start with, ramping towards the color option |
color ramp palette function
Teaching Lab Color Palette Maker
tl_palette2(n = 6, base_color_start = NULL, end_color_start = NULL)
tl_palette2(n = 6, base_color_start = NULL, end_color_start = NULL)
n |
number of colors to generate |
base_color_start |
the base color of the palette to start with, ramping from the color option |
base_color_end |
the base color of the palette to end with, ramping towards the color option |
color ramp palette function
Automatically scaled stacked bar chart with TL theming
tl_select_percent(data, percent_equal)
tl_select_percent(data, percent_equal)
data |
the data for the plotter to use, should include all columns of interest |
percent_equal |
string inputs to find the percent of the column that equals those values |
a percentage as a string